https://github.com/GoogleChrome/puppeteer
Puppeteer is a Node library which provides a high-level API to control headless Chrome over the DevTools Protocol. It can also be configured to use full (non-headless) Chrome.
以前用 phantomjs,现在可以用 Puppeteer,不知道这个库能维护多久。phantomjs 能做的事情,Puppeteer 都能做!
/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://google.com', {waitUntil: 'networkidle'});
// Type our query into the search bar
await page.type('puppeteer');
await page.click('input[type="submit"]');
// Wait for the results to show up
await page.waitForSelector('h3 a');
// Extract the results from the page
const links = await page.evaluate(() => {
const anchors = Array.from(document.querySelectorAll('h3 a'));
return anchors.map(anchor => anchor.textContent);
});
console.log(links.join('\n'));
browser.close();
})();
➜ puppeteer node search.js
puppeteerの意味 - 英和辞典 Weblio辞書
GitHub - GoogleChrome/puppeteer: Headless Chrome Node API
puppeteerの意味・用例|英辞郎 on the WEB:アルク
--headless時代の本命? Chrome を Node.jsから操作するライブラリ ...
Puppeteer - Wikipedia
Puppeteer (video game) - Wikipedia
puppeteer - ウィクショナリー日本語版
MAX - Puppeteer (OFFICIAL MUSIC VIDEO) - YouTube
Puppeteer: Headless Chrome Node API | Hacker News
Puppeteer™ Game | PS3 - PlayStation