Puppeteer

Tell Puppeteer to open Chrome tab instead of window

狂风中的少年 提交于 2020-07-06 20:32:06
问题 If I have an existing Google Chrome window open, I'd like to tell puppeteer to open a new tab instead of opening a new window. Is there a way to do that? is there some option or flag I can pass to puppeteer to accomplish this? I have: const puppeteer = require('puppeteer'); (async function () { const b = await puppeteer.launch({ devtools: true, openInExistingWindow: true /// ? something like this? }); const page = await b.newPage(); await page.goto('https://example.com'); })(); 回答1: const

How to use evaluateOnNewDocument and exposeFunction?

蹲街弑〆低调 提交于 2020-07-01 06:46:20
问题 Recently, I used Puppeteer for a new project. I have a few questions about thea part of the API I don't understand. The documentation is very simple for these API introductions: page.exposeFunction page.evaluateOnNewDocument Can I have a detailed demo to gain a better understanding? 回答1: Summary: The Puppeteer function page.exposeFunction() essentially allows you to access Node.js functionality within the Page DOM Environment. On the other hand, page.evaluateOnNewDocument() evaluates a

How to use evaluateOnNewDocument and exposeFunction?

守給你的承諾、 提交于 2020-07-01 06:46:02
问题 Recently, I used Puppeteer for a new project. I have a few questions about thea part of the API I don't understand. The documentation is very simple for these API introductions: page.exposeFunction page.evaluateOnNewDocument Can I have a detailed demo to gain a better understanding? 回答1: Summary: The Puppeteer function page.exposeFunction() essentially allows you to access Node.js functionality within the Page DOM Environment. On the other hand, page.evaluateOnNewDocument() evaluates a

How to deal with the captcha when doing Web Scraping in Puppeteer?

落花浮王杯 提交于 2020-07-01 03:52:48
问题 I'm using Puppeteer for Web Scraping and I have just noticed that sometimes, the website I'm trying to scrape asks for a captcha due to the amount of visits I'm doing from my computer. The captcha form looks like this one: So, I would need help about how to handle this. I have been thinking about sending the captcha form to the client-side since I use Express and EJS in order to send the values to my index website, but I don't know if Puppeteer can send something like that. Any ideas? 回答1:

Passing very long url to Puppeteer - is there a better way?

徘徊边缘 提交于 2020-06-29 04:31:23
问题 So a git issue had me roll back about two weeks of work - Im currently trying to pass an array of about 3300 string to a handlebars template then trying to print that as a pdf - my issue is I'm pretty sure my pupepteer URL is being cut off at 3000 characters. Im at a loss for a workaround. <<<< my data logs as -----> Array(3330) [Object, Object, Object, Object, Object, Object, Object, Object, …] >>> var templateHtml = fs.readFileSync(path.join(process.cwd(), 'template.html'), 'utf8'); var

Node.js + Puppeteer on Docker, No usable sandbox

为君一笑 提交于 2020-06-29 03:54:10
问题 i'm building a node.js LTS application. I followed puppeteer documentation, so my Dockerfile has this content: FROM node:12.18.0 WORKDIR /home/node/app ADD package*.json ./ # Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others) # Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer # installs, work. RUN apt-get update \ && apt-get install -y wget gnupg \ && wget -q -O - https:/

puppeteer request.continue can not work with header host overrided

此生再无相见时 提交于 2020-06-27 16:48:08
问题 Tell us about your environment: Puppeteer version: 1.19.0 Platform / OS version: Debian 9 URLs (if applicable): Node.js version: 8 What is the expected result? I want override the request's host in header. Such as a request url: http://a.com/x.jpg . The DNS resolver may be parse the host to a slower ip address, but I know ther is a better ip like 1.2.3.4 . I want to change the url with the ip addrees and modify the host in request header. like from curl http://a.com/x.jpg to curl --header

In puppeteer how to wait for pop up page to finish loading?

假如想象 提交于 2020-06-27 16:29:46
问题 In the following example how do I wait for the pop up window to finish loading? After clikcing the google icon you get a pop up window to login to gmail, when I try to interact with the second page it is undefined (as I don't know how to wait for it to fully load. Any advice? const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch({headless: false}); page = await browser.newPage(); await page.goto("https://www.example.com/signin"); await page

Is there a way to detect if a web client is a puppeteer instance? [duplicate]

大憨熊 提交于 2020-06-27 14:37:11
问题 This question already has an answer here : Headless browser detection (1 answer) Closed last year . I want to detect if a client visiting a website is using puppeteer instead of being a real user. Does puppeteer add a request header that tells that the request is coming from puppeteer? Edit: Imagine I created a website. I want to block users using puppeteer because I want my users to be "real" users (person that clicks a button, not a script imitating a button click). I want to know if there

Play mp4 in chromium with puppeteer, windows

帅比萌擦擦* 提交于 2020-06-26 06:41:53
问题 I'm developing with puppeteer in node on windows 10. The problem is that when I open a site playing an mp4 file the browser says me that it is not supported. I found this package: chromium-codecs-ffmpeg-nonfree; but it is for linux! How can I play .mp4 in Chromium with puppeteer on windows? 回答1: The Puppeteer Documentation has an answer for this: Q: What features does Puppeteer not support? You may find that Puppeteer does not behave as expected when controlling pages that incorporate audio