Просмотр исходного кода

Merge pull request #14 from iperzic/feat/waitforselector-timeout-configuration

Add `waitForSelectorTimeout` configuration option
Steve Sewell 1 год назад
Родитель
Сommit
3c466c7b80
3 измененных файлов с 5 добавлено и 1 удалено
  1. 2 0
      README.md
  2. 2 0
      config.ts
  3. 1 1
      src/main.ts

+ 2 - 0
README.md

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

+ 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);