Puppeteer

How is defined `resourceType` value provided by the DevTool protocol?

最后都变了- 提交于 2019-12-22 09:25:04
问题 While using Puppeteer or Chrome DevTools APIs, you can get a value for resourceType (on Request object in Puppeteer and on Page object in Chrome DevTools). How does this value is establish by the "rendering engine" (as called in the documentation)? Possible values being: Document , Stylesheet , Image , Media , Font , Script , TextTrack , XHR , Fetch , EventSource , WebSocket , Manifest , Other API documentation: Puppeteer API and Chrome DevTools API Similar question on stackoverflow: Is There

npm install puppeteer showing permission denied errors

旧城冷巷雨未停 提交于 2019-12-22 07:07:37
问题 I'm unable to install puppeteer as a project dependency, and I've tried re-installing node. Anyone have an idea on how to fix this? Running Ubuntu 17.10 x64 sudo apt-get purge nodejs; curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -; apt-get install -y nodejs; sudo npm install -g n; sudo n stable; Node versions: $ node -v v9.4.0 $ npm -v 5.6.0 I try to install: root@server:/var/www/html# npm install --save puppeteer Error message: > puppeteer@1.1.0 install /var/www/html/node

Error executing Puppeteer from PHP

走远了吗. 提交于 2019-12-22 00:20:00
问题 I have a node script which converts a webpage into a PDF document. The user enters some content and PHP builds a HTML page, which then is used in a node script (that runs Puppeteer, using a slightly modified version of an example script) to convert it to PDF. But when I exec in PHP the command to run the node script, it fails with the following error: (node:14832) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome! [0424/165455.239499:ERROR:icu_util.cc(133)] Invalid file

Why can't I access 'window' in an exposeFunction() function with Puppeteer?

▼魔方 西西 提交于 2019-12-21 04:34:10
问题 I have a very simple Puppeteer script that uses exposeFunction() to run something inside headless Chrome. (async function(){ var log = console.log.bind(console), puppeteer = require('puppeteer'); const browser = await puppeteer.launch(); const page = await browser.newPage(); var functionToInject = function(){ return window.navigator.appName; } await page.exposeFunction('functionToInject', functionToInject); var data = await page.evaluate(async function(){ console.log('woo I run inside a

How to use Puppeteer in an Angular application

和自甴很熟 提交于 2019-12-21 03:32:54
问题 My question is simple but i don't understand if it's possible and in this case how it's possible ? I would like to use the puppeteer library in a angular application. https://www.npmjs.com/package/puppeteer it's the npm installation. But i don't understand how i can use it. For example i just want to make this script : const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://example.com');

puppeteer : how can i wait for ajax request and process the result

雨燕双飞 提交于 2019-12-20 14:14:06
问题 so i open a website , waith for all redirects to be done capture captcha image and send it vie nodejs to a user an recive the typed captcha const browser = await puppeteer.launch({headless: false}); const page = await browser.newPage(); await page.goto('http://localhost/p1.php' ); await page.waitForNavigation(); const captcha_image = await page.$eval('#security', e => e.getAttribute('src')); io.emit('send_captcha_to_client' , {text : captcha_image }); var captcha = await captchaPromise; after

Collect elements by class name and then click each one - Puppeteer

…衆ロ難τιáo~ 提交于 2019-12-20 09:58:12
问题 Using Puppeteer, I would like to get all the elements on a page with a particular class name and then loop through and click each one Using jQuery I can achieve this with var elements = $("a.showGoals").toArray(); for (i = 0; i < elements.length; i++) { $(elements[i]).click(); } How would I achieve this using Puppeteer? Update Tried out Chridam's answer below but I couldn't get to work (though answer helpful so thanks due there) so I tried the following and this works await page.evaluate(() =

How to scrape javascript hash links content?

岁酱吖の 提交于 2019-12-20 07:06:35
问题 Hi im a bit new in web scraping using Puppeter im currently im facing the next problem: in the site where im trying to extract information i have a bootstrap table with a typical js pagination like the examples from: https://getbootstrap.com/docs/4.1/components/pagination/ when i check the page html with Chrome inspector all i can see is 2 and when i check link location i see https://webpage.com/works# how i can know how many pages are in total? and how i can click them? i don't understand

puppeteer stream playing <video> to node.js buffer

守給你的承諾、 提交于 2019-12-20 05:53:17
问题 using Puppeteer I'm able to navigate to a certain video src URL, and the MP4 (using a custom build of chronium) plays fine. NOW: I want to be able to get the video data that's playing and send it to some kind of buffer in node.js that can be saved as a file or sent to a client via a websocket or sent as a response etc.... but I'm not sure how to do it, all I have is the video playing. I'm not able to just send the URL over to node.js, because in order to view the video file you have to go

Puppeteer: How to get total bytes sent / received in a page

不羁岁月 提交于 2019-12-19 11:28:08
问题 Is there any puppeteer api/workaround to get total bytes sent / received in a page. For example below code gives me all timing stats. await page.evaluate(() => JSON.stringify(window.performance.timing)) Similarly is there any way or work around I can get total bytes / sent received in a page. Byte counts should include HTTP, Websocket, XHR request / response headers, body all. 回答1: By using const perfEntries = JSON.parse( await page.evaluate(() => JSON.stringify(performance.getEntries())) );