Skip to content

Commit

Permalink
Merge pull request #108 from ZiuChen/fork
Browse files Browse the repository at this point in the history
fix: 支持从外部设置Page的超时时间timeout
  • Loading branch information
iDerekLi authored Feb 10, 2023
2 parents 80e5f7e + b1ff08a commit 3a59e38
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/juejin-helper/src/utils/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export default class JuejinBrowser {
async visitPage(path: string = "", options = {}): Promise<Page> {
const opts = Object.assign(
{
viewport: { width: 414, height: 820 }
viewport: { width: 414, height: 820 },
timeout: 30000
},
options
);
Expand All @@ -36,6 +37,7 @@ export default class JuejinBrowser {
const page = await browser.newPage();

await page.setViewport(opts.viewport);
page.setDefaultTimeout(opts.timeout);

const cookiesString = this.juejin.cookie.toString();
const cookiesArray = cookiesString.split(/;\W+/).map(item => item.split("="));
Expand Down

0 comments on commit 3a59e38

Please sign in to comment.