浏览代码

feat: add waitForSelectorTimeout config option

Igor Perzic 1 年之前
父节点
当前提交
4c892e6d1e
共有 2 个文件被更改,包括 3 次插入1 次删除
  1. 2 0
      config.ts
  2. 1 1
      src/main.ts

+ 2 - 0
config.ts

@@ -18,6 +18,8 @@ type Config = {
     page: Page;
     pushData: (data: any) => Promise<void>;
   }) => Promise<void>;
+    /** Optional timeout for waiting for a selector to appear */
+  waitForSelectorTimeout?: number;
 };
 
 export const config: Config = {

+ 1 - 1
src/main.ts

@@ -33,7 +33,7 @@ if (process.env.NO_CRAWL !== "true") {
       log.info(`Crawling ${request.loadedUrl}...`);
 
       await page.waitForSelector(config.selector, {
-        timeout: 1000,
+        timeout: config.waitForSelectorTimeout ?? 1000,
       });
 
       const html = await getPageHtml(page);