This link: https://www.cnblogs.com/hchengmx/p/11006263.html
1. PhantomJS Introduction
Before introducing the puppeteer must introduce phantomjs, phantomjs is that one can use JavaScript programming of a headless browser, which uses QtWebKit in the back end.
However, according to https://github.com/ariya/phantomjs/issues/15344
Due to the lack of effective contribution, I will put this project archive.
If someday, if we want to re-develop spantomjs, we will re-run it.
PhantomJS version 2.1.1 will be the last known stable version.
2. What is the puppeteer
puppeteer is a Node library, developed by Google official, it uses DevTools protocol , provides a powerful api to control headless in chrome or Chromium. It may also be provided to complete the control (non headless mode) or chrome Chromium.
3. What can be done puppeteer
- Screenshots and generate PDF for each page;
- Crawls the web, what we call reptiles;
- Automated form submission, UI testing, such as keyboard input;
- Create a new automated test environment. Using the latest JavaScript and browser capabilities to run the test directly in the latest version of Chrome in;
- Creating a website for your Timeline the trace , help you diagnose performance problems;
- Test Chrome's Extensions;
4. puppeteer和puppeteer-core
Since version 1.7.0, Chrome will officially release a puppeteer-core package, to puppeteer the main difference is that this package will not default download Chromium, more visible difference here .
5. Puppeteer Organization
According puppeteer official explanation of the current organizational structure puppeteer follows.
- puppeteer by DevTools protocol to communicate with the browser.
- Browser instance can have a plurality of BrowserContext.
- BrowserContext defines a browser session, she can have more than one page.
- Page has at least one frame: main frame. . There may also be other frames frame or iframe created.
- Frame with at least one execution context (execution context)
- Worker have a single execution context (execution context), and WebWorkers communication.
References: