feat(FtbCrawlNetDy): 调整抖音爬虫浏览器窗口大小并优化等待逻辑

设置浏览器窗口大小为1600x900,并将等待时间从1秒增加到5秒,同时直接设置dyCookie为true以避免不必要的循环等待。

feat(FtbCrawlNetMt): 设置美团爬虫浏览器窗口大小

统一设置浏览器窗口大小为1600x900,提升页面加载与交互的一致性。
This commit is contained in:
wangchunxiang
2025-10-14 15:06:21 +08:00
parent 0a810aadb0
commit a9b3ea942b
2 changed files with 11 additions and 4 deletions

View File

@@ -27,7 +27,10 @@ public class FtbCrawlNetDy extends AbstractFtbCrawlNetBase implements FtbCrawlNe
public void executeCookieIntercept() { public void executeCookieIntercept() {
// 启动可见浏览器 // 启动可见浏览器
try (Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false))) { 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(); Page page = context.newPage();
AtomicBoolean dyCookie = new AtomicBoolean(false); AtomicBoolean dyCookie = new AtomicBoolean(false);
// 监听网络请求 // 监听网络请求
@@ -43,7 +46,8 @@ public class FtbCrawlNetDy extends AbstractFtbCrawlNetBase implements FtbCrawlNe
new Page.NavigateOptions().setTimeout(6000000)); new Page.NavigateOptions().setTimeout(6000000));
while (!dyCookie.get()) { while (!dyCookie.get()) {
try { try {
Thread.sleep(1000); Thread.sleep(5000);
dyCookie.set(true);
} catch (InterruptedException e) { } catch (InterruptedException e) {
log.warn("等待过程中被中断", e); log.warn("等待过程中被中断", e);
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();

View File

@@ -29,7 +29,10 @@ public class FtbCrawlNetMt extends AbstractFtbCrawlNetBase implements FtbCrawlNe
public void executeCookieIntercept() { public void executeCookieIntercept() {
// 启动可见浏览器 // 启动可见浏览器
try (Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false))) { 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 // 美团cookie
AtomicBoolean mtCookie = new AtomicBoolean(false); AtomicBoolean mtCookie = new AtomicBoolean(false);
// 大众点评cookie // 大众点评cookie