feat(FtbCrawlNetDy): 调整抖音爬虫浏览器窗口大小并优化等待逻辑
设置浏览器窗口大小为1600x900,并将等待时间从1秒增加到5秒,同时直接设置dyCookie为true以避免不必要的循环等待。 feat(FtbCrawlNetMt): 设置美团爬虫浏览器窗口大小 统一设置浏览器窗口大小为1600x900,提升页面加载与交互的一致性。
This commit is contained in:
@@ -27,7 +27,10 @@ public class FtbCrawlNetDy extends AbstractFtbCrawlNetBase implements FtbCrawlNe
|
||||
public void executeCookieIntercept() {
|
||||
// 启动可见浏览器
|
||||
try (Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false))) {
|
||||
BrowserContext context = browser.newContext();
|
||||
// 设置浏览器窗口大小为1920x1080
|
||||
Browser.NewContextOptions contextOptions = new Browser.NewContextOptions()
|
||||
.setViewportSize(1600, 900);
|
||||
BrowserContext context = browser.newContext(contextOptions);
|
||||
Page page = context.newPage();
|
||||
AtomicBoolean dyCookie = new AtomicBoolean(false);
|
||||
// 监听网络请求
|
||||
@@ -43,7 +46,8 @@ public class FtbCrawlNetDy extends AbstractFtbCrawlNetBase implements FtbCrawlNe
|
||||
new Page.NavigateOptions().setTimeout(6000000));
|
||||
while (!dyCookie.get()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(5000);
|
||||
dyCookie.set(true);
|
||||
} catch (InterruptedException e) {
|
||||
log.warn("等待过程中被中断", e);
|
||||
Thread.currentThread().interrupt();
|
||||
|
||||
@@ -29,7 +29,10 @@ public class FtbCrawlNetMt extends AbstractFtbCrawlNetBase implements FtbCrawlNe
|
||||
public void executeCookieIntercept() {
|
||||
// 启动可见浏览器
|
||||
try (Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false))) {
|
||||
BrowserContext context = browser.newContext();
|
||||
// 设置浏览器窗口大小为1920x1080
|
||||
Browser.NewContextOptions contextOptions = new Browser.NewContextOptions()
|
||||
.setViewportSize(1600, 900);
|
||||
BrowserContext context = browser.newContext(contextOptions);
|
||||
// 美团cookie
|
||||
AtomicBoolean mtCookie = new AtomicBoolean(false);
|
||||
// 大众点评cookie
|
||||
|
||||
Reference in New Issue
Block a user