Puppeteer

How to pass userDataDir profile folder to Puppeteer

情到浓时终转凉″ 提交于 2019-12-13 00:02:18
问题 I want to pass a custom profile to Puppeteer. To start I've tried to pass my real Google Chrome profile: const browser = await puppeteer.launch({ userDataDir: '/Users/[USERNAME]/Library/Application Support/Google/Chrome/Default', headless: false, slowMo: 250, ... } but when the browser opens if I go to Settings it shows Person 1 rather than the data from my Google Chrome profile The userDataDir path above is what is shown in Profile Path when on Google Chrome I visit chrome://version (where

Puppeteer - New window about:blank

痴心易碎 提交于 2019-12-12 23:31:20
问题 Am trying to interact with a new window that pops from a website when hittin a link. When this new window opens the link is: about:blank. When the link have something other than blank it works. Does anybody knows an workaround? Working (Link with something): const newPagePromise = new Promise(x => browser.once('targetcreated', target => x(target.page()))); await page.click('#link-of-new-window'); const newPage = await newPagePromise; Not Working (about:blank): //not entering browser.on(

How can I pause and wait for user input with Puppeteer?

人盡茶涼 提交于 2019-12-12 18:31:07
问题 I need to make Puppeteer pause and wait for user input of username and password before continuing. It is a nodejs 8.12.0 app. (async () => { const browser = await puppeteer.launch({headless: false}); const page = await browser.newPage(); await page.goto('https://www.myweb.com/login/'); //code to wait for user to enter username and password, and click `login` const first_page = await page.content(); //do something await browser.close(); )}(); Basically the program is halted and waits until the

Allowing to run Flash on all sites in Puppeteer

♀尐吖头ヾ 提交于 2019-12-12 10:56:22
问题 Disclaimer: I know that Flash will be abandoned by the end of 2020, but I simply cannot drop the case and need to have flash in Puppeteer, though I don't like it either. I need to crawl certain flash sites and take a screenshot of them, for later programatic comparison. I could provide a finite list of domains that I need to check against (though the list may change in time, so it'd be great to be able to somehow load them at the runtime). Been searching through the Internet after solutions

Puppeteer can't find selector

扶醉桌前 提交于 2019-12-12 10:37:54
问题 I'm attempting to do a bit of web scraping using Puppeteer, but the script seems unable to find the selector I'm looking for. Basically this code: const puppeteer = require('puppeteer'); let scrape = async () => { const year = 18; const browser = await puppeteer.launch({headless: false}); const page = await browser.newPage(); await page.goto('https://cobbcounty.org/index.php?option=com_wrapper&view=wrapper&Itemid=2008'); await page.waitFor(5000); var id = ''; for(i=0;i<10000;i++){ id = i;

How to detect version of chrome used with puppeteer?

ⅰ亾dé卋堺 提交于 2019-12-12 09:57:07
问题 I read that puppeteer uses the latest version of chrome with it, where can I find which version it is using ? I don't want to access navigator object on the window to get it. Basically nothing runtime. Just want to know if puppeteer as a package lists out its dependency somewhere Basically, I want to look up what all CSS and javascript support I can assume to be there from other sites like 'can I use' or chrome references. 回答1: Use the browser.version() function to find out during runtime

Can a har file be programmatically generated from headless chrome using Puppeteer?

点点圈 提交于 2019-12-12 09:39:47
问题 I would like to control a headless chrome instance using puppeteer, taking snapshots and clicking on various page elements, while capturing a har file. Is this possible? I have looked at the API but haven't found anything useful. 回答1: There is no HAR generator helper in Puppeteer. But you can use chrome-har to generate HAR file. const fs = require('fs'); const { promisify } = require('util'); const puppeteer = require('puppeteer'); const { harFromMessages } = require('chrome-har'); // list of

Continue on Null Value of Result (Nodejs, Puppeteer)

点点圈 提交于 2019-12-12 05:39:49
问题 I'm just starting to play around with Puppeteer (Headless Chrome) and Nodejs. I'm scraping some test sites, and things work great when all the values are present, but if the value is missing I get an error like: Cannot read property 'src' of null (so in the code below, the first two passes might have all values, but the third pass, there is no picture, so it just errors out). Before I was using if(!picture) continue; but I think it's not working now because of the for loop. Any help would be

Puppeteer to listen for map.on('load') from within Node

无人久伴 提交于 2019-12-11 19:07:13
问题 Using Puppeteer to listen for map.on('load') from within Node. (async () => { const browser = await puppeteer.launch({ headless: false, devtools: true }); const page = await browser.newPage(); function nodeLog(msg) { console.log(msg); } page.on('load', async () => { await page.evaluate(() => { window.map.on('load', () => { console.log("This runs on the index.html js but I do not need that"); nodeLog("WHY IS THIS NOT WORKING??") }) }) }); await page.goto(`file:${__dirname + '/index.html'}`); }

puppeteer waits for first element to load

和自甴很熟 提交于 2019-12-11 17:41:51
问题 I'm trying to check the first element class to load in my page to execute my code. For example, my page can have 3 different states, it can have a popup with class .a or it can have a page with class .b or a page with class .c . So I would like to wait one of them to load and get which one loaded first. I tried to do it with Promise.race . My code: await page.goto('myurl', { waitUntil: 'networkidle2', timeout: 30000 }).then(async () => { await Promise.race([ page.waitForSelector('.a'), page