Puppeteer

How to wait for all images to load from page.evaluate function in puppeteer when the DOM is populated using a client side function

拈花ヽ惹草 提交于 2020-06-25 03:23:08
问题 I am trying to make the code execution wait for all images to load before puppeteer takes a screenshot. My DOM gets populated when initData() function is called, which is defined in the client side js file. Delay or timeout is an option but I am sure there must be a more efficient way of doing it. (async (dataObj) => { const url = dataObj.url; const payload = dataObj.payload; const browser = await puppeteer.launch({ headless: false,devtools:false}); const page = await browser.newPage(); await

Puppeteer: use function inside page.evaluate

三世轮回 提交于 2020-06-17 00:04:50
问题 I need to use a function inside page.evaluate with puppeteer. I use exposeFunction and I need to send the full Element to my function I have a simple example: const puppeteer = require('puppeteer'); const myFunction = (content) => { console.log(content.outerHTML); // empty } (async () => { const browser = await puppeteer.launch() const page = await browser.newPage() page.on('console', msg => console.log('PAGE LOG:', msg.text())); const url = "https://www.google.com"; await page.goto(url,{

How to use Puppeteer to take Screenshots of Pages that Contain Video

喜欢而已 提交于 2020-06-11 11:17:31
问题 I'm currently using Puppeteer to open a site and take a screenshot of a video. However, the default Chromium browser that puppeteer runs doesn't work with video types. I launched with a local version of Chrome with Puppeteer and everything is working. Is there a way to open an actual chrome browser instance with puppeteer without having to specify a local link to the .exe to make it more scalable and less reliant on a directory when being hosted? Puppeteer 2.0.0 Note: I'm running a non

How to use Puppeteer to take Screenshots of Pages that Contain Video

做~自己de王妃 提交于 2020-06-11 11:17:31
问题 I'm currently using Puppeteer to open a site and take a screenshot of a video. However, the default Chromium browser that puppeteer runs doesn't work with video types. I launched with a local version of Chrome with Puppeteer and everything is working. Is there a way to open an actual chrome browser instance with puppeteer without having to specify a local link to the .exe to make it more scalable and less reliant on a directory when being hosted? Puppeteer 2.0.0 Note: I'm running a non

puppeteer : how check if browser is still open and working

感情迁移 提交于 2020-06-09 10:28:39
问题 im trying to open multiple tabs in a single browser instance , after they're done i close the tabs and then re-opening those tabs every x seconds ... but i want to keep the browser itself open so i dont have to login in each tab on every loop so the browser remains open , tabs open and close here is my simplified code , pleas ignore syntax erros var global_browser = false ; async function init_puppeteer( settings ) { if(global_browser === false ) global_browser = await puppeteer.launch(

puppeteer : how check if browser is still open and working

我们两清 提交于 2020-06-09 10:28:04
问题 im trying to open multiple tabs in a single browser instance , after they're done i close the tabs and then re-opening those tabs every x seconds ... but i want to keep the browser itself open so i dont have to login in each tab on every loop so the browser remains open , tabs open and close here is my simplified code , pleas ignore syntax erros var global_browser = false ; async function init_puppeteer( settings ) { if(global_browser === false ) global_browser = await puppeteer.launch(

Puppeteer - counting elements in the DOM

ε祈祈猫儿з 提交于 2020-05-28 12:01:12
问题 I know this has been answered here Puppeteer - counting elements by class name Yet, following this approach, I get 0 as my result using page.$$ - in my test, I always get 0 console.log((await page.$$('.clients-table > tbody > tr > td')).length); verified in browser using document.querySelectorAll() and the result is 4 How could this be??? 回答1: The data is not loaded yet. You can use waitForSelector to ensure the data is loaded properly. So just add this before counting the numbers, await page

Running pypupeteer in FLASK gives ValueError: signal only works in main thread

社会主义新天地 提交于 2020-05-27 04:58:05
问题 I am trying to integrate pyppeteer in a flask app. I have python script that runs pyppeteer and takes a screenshot of a page.This is working file if I run the script individually. The PROBLEM is the same script does not work when i run it in a FLASK APP. I get the following error : loop.run_until_complete(capture(url, 123123)) File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/ Versions/3.7/lib/python3.7/asyncio/base_events.py", line 568, in run_until_complete return future

How to avoid being detected as bot on Puppeteer and Phantomjs?

Deadly 提交于 2020-05-24 11:32:53
问题 Puppeteer and PhantomJS are similar. The issue I'm having is happening for both, and the code is also similar. I'd like to catch some informations from a website, which needs authentication for viewing those informations. I can't even access home page because it's detected like a "suspicious activity", like the SS: https://i.imgur.com/p69OIjO.png I discovered that the problem doesn't happen when I tested on Postman using a header named Cookie and the value of it's cookie caught on browser,

How to avoid being detected as bot on Puppeteer and Phantomjs?

谁都会走 提交于 2020-05-24 11:32:10
问题 Puppeteer and PhantomJS are similar. The issue I'm having is happening for both, and the code is also similar. I'd like to catch some informations from a website, which needs authentication for viewing those informations. I can't even access home page because it's detected like a "suspicious activity", like the SS: https://i.imgur.com/p69OIjO.png I discovered that the problem doesn't happen when I tested on Postman using a header named Cookie and the value of it's cookie caught on browser,