Puppeteer

puppeteer wait for network idle after click

白昼怎懂夜的黑 提交于 2020-01-24 19:31:09
问题 None of the existing Q&As have a clean solution for this question, e.g., puppeteer wait for page update after button click (no navigation) How can I wait for network idle after click on an element in puppeteer? So here is a simple working example for people to see/try/fix: const puppeteer = require('puppeteer'); (async() => { const browser = await puppeteer.launch({headless: true}); try { const page = await browser.newPage(); await page.setViewport({width: 800,height: 800}); const response =

Is it possible to pass a function to Puppeteer's page.evaluate()

陌路散爱 提交于 2020-01-24 18:13:20
问题 I am using Puppeteer to parse a webpage and can't find a definitive answer to my question. I am trying to pass a function as an argument to page.evaluate() An object is OK to pass but can't seem to pass a function. Here's a contrived example: const obj = { thing: 'thing1', }; const myfunction = () => { return `great ${stuff}`; }; await page.evaluate((obj, function)=>{ const thing = myfunction; },(obj, function)); Is it possible to pass a function as an argument to puppeteers page.evaluate()?

Is it possible to pass a function to Puppeteer's page.evaluate()

佐手、 提交于 2020-01-24 18:13:12
问题 I am using Puppeteer to parse a webpage and can't find a definitive answer to my question. I am trying to pass a function as an argument to page.evaluate() An object is OK to pass but can't seem to pass a function. Here's a contrived example: const obj = { thing: 'thing1', }; const myfunction = () => { return `great ${stuff}`; }; await page.evaluate((obj, function)=>{ const thing = myfunction; },(obj, function)); Is it possible to pass a function as an argument to puppeteers page.evaluate()?

Is it possible to pass a function to Puppeteer's page.evaluate()

依然范特西╮ 提交于 2020-01-24 18:13:07
问题 I am using Puppeteer to parse a webpage and can't find a definitive answer to my question. I am trying to pass a function as an argument to page.evaluate() An object is OK to pass but can't seem to pass a function. Here's a contrived example: const obj = { thing: 'thing1', }; const myfunction = () => { return `great ${stuff}`; }; await page.evaluate((obj, function)=>{ const thing = myfunction; },(obj, function)); Is it possible to pass a function as an argument to puppeteers page.evaluate()?

How to perform right click with Puppeteer?

房东的猫 提交于 2020-01-24 11:01:31
问题 I'm trying to perform right-click with Puppeteer. I've tried to add the option: await component.click({ button: "right" }) But all I get is a regular click on the component. I followed Puppeteer's API. What am I doing wrong? 回答1: It is correct that you can use elementHandle.click() with the button option set to 'right' to right-click an element: const example = await page.$( '#example' ); await example.click( { button : 'right' }); According to the Official Documentation for elementHandle

How do we pass authentication token in headless chrome in google puppeteer?

流过昼夜 提交于 2020-01-24 05:41:13
问题 I want to pass authentication token(JWT) in puppeteer headers, for the pdf view with headless chrome in my application? We are using react as our front-end UI. And using puppeteer we are able to generate pdf, but the link to pdf we need to authorize using JWT How do we pass the jwt in headers, does puppeteer support Auth token in headers? Please help. Thanks 回答1: To pass additional headers in the request, you can use the function page.setExtraHTTPHeaders. Quote from the docs linked above: The

Puppeteer fingerprint simulation

谁说我不能喝 提交于 2020-01-24 05:27:06
问题 By doing tests I am faced with JavaScript fingerprinting such like: audio context fingerprinting opengl fingerprinting canvas fingerprinting installed fonts fingerprinting installed plugins fingerprinting webrtc I want to replace the results of the fingerprinting with simulated results. How do fingerprints work and how can I simulate/fake the fingerprinting results? 回答1: To change the outcome of these fingerprints, you have to understand how they work. Let's look at an example: The Canvas

How can I disable webRTC local IP leak with puppeteer?

早过忘川 提交于 2020-01-23 17:37:07
问题 I tried: const browser = await puppeteer.launch({args: ['--enable-webrtc-stun-origin=false', '--enforce-webrtc-ip-permission-check=false']}); But this is not working. Next I tried: const targets = await browser.targets(); const backgroundPageTarget = targets.find(target => target.type() === 'background_page'); const backgroundPage = await backgroundPageTarget.page(); await backgroundPage.evaluateevaluateOnNewDocument(() => { chrome.privacy.network.webRTCIPHandlingPolicy.set({ value: "default

Connecting Browsers in Puppeteer

雨燕双飞 提交于 2020-01-23 16:39:07
问题 Is it possible to connect a browser to puppeteer without instantiating it in puppeteer? For example, running an instance of chromium like a regular user and then connecting that to an instance of puppeteer in code? 回答1: The answer is Yes and No. You can connect to an existing using the connect function: const browserURL = 'http://127.0.0.1:21222'; const browser = await puppeteer.connect({browserURL}); But, if you want to use those 2 lines you need to launch Chrome with the "--remote-debugging

How to select elements within an iframe element in Puppeteer

北城以北 提交于 2020-01-23 12:58:46
问题 Since ESPN does not provide an API, I am trying to use Puppeteer to scrape data about my fantasy football league. However, I am having a hard time trying to login using puppeteer due to the login form being nested with an iframe element. I have gone to http://www.espn.com/login and selected the iframe. I can't seem to select any of the elements within the iframe except for the main section by doing frame.$('.main') This is the code that seems to get the iframe with the login form. const