当前位置:网站首页>Browser class for getting started with puppeter

Browser class for getting started with puppeter

2022-06-11 10:05:00 crayon-shin-chan

file :puppeteer/api.md at main · puppeteer/puppeteer · GitHub

1. brief introduction

adopt puppeteer.launch or puppeteer.connect  Connect to Chromium Instance creates a browser instance

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await browser.close();
})();

2.pages

Returns an array of all open pages in the browser .

In the case of multiple browser contexts , Returns an array containing all the context pages

  Invisible pages , Such as background_page , Will not be listed , Can pass  Target.page find

pages(): Promise<Page[]>;

There will be a default page when the browser is created

3.newPage

Create a new... In the default browser context Page

<
原网站

版权声明
本文为[crayon-shin-chan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110956100593.html