Puppeteer

attach to previously opened puppeteer driver

白昼怎懂夜的黑 提交于 2019-12-06 04:16:06
问题 Is it possible to reattach to an existing puppeteer ? open puppeteer chrome browser. node script ends without closing browser. new script attaches and continue with the same browser. 回答1: For those who stumble upon this, here's an example of how I've got it working: const puppeteer = require('puppeteer'); puppeteer.connect({"browserWSEndpoint" : "ws://some_string"}).then(async browser => { console.log("bla bla"); ... }); The browser.wsEndpoint you can find from the previous session: const

Running headless Chrome / Puppeteer with --no-sandbox

限于喜欢 提交于 2019-12-06 02:20:28
问题 Background I built an application that uses Puppeteer on my localhost. Now that I am trying to deploy it into a debian environment the script that runs Puppeteer is timing out. After researching it I realized it is a common problem. Most debian environments are missing the dependencies needed to run Chromium. Problem I found some recommended ways to run the application using Docker here. I can run the application using Docker, but once I add the Chrome specific data to my Docker file I am

How to inspect network traffic and get the URL of resource requests?

元气小坏坏 提交于 2019-12-06 01:51:19
I want to monitor the network of a page and get all the URLs of the JavaScript network events, similar to what PhantomJS' page.onResourceRequested is doing, but I couldn't figure it out how to do this with Google Chrome's Puppeteer. I've been dabbling with Google Chrome's puppeteer , but I couldn't figure out how to make it work, as the output of it looks like this: Page { domain: null, _events: { request: [Function] }, _eventsCount: 1, _maxListeners: undefined, _client: Session { domain: null, _events: { 'Page.frameAttached': [Function], 'Page.frameNavigated': [Function], 'Page.frameDetached'

nodejs puppeteer linux(centos)环境部署以及用puppeteer简单截图

天涯浪子 提交于 2019-12-06 01:04:15
nodejs puppeteer linux(centos)环境部署以及用puppeteer简单截图 1.安装Node环境 如果有安装Node请忽略第1点 #下载 cd /usr/local/src wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz #解压 tar -Jxf node-v10.15.3-linux-x64.tar.xz #将文件夹移动到 /usr/local/bin mv node-v10.15.3-linux-x64 /usr/local/bin/node-v10.15.3-linux-x64 #配置环境变量 vi /etc/profile 在"export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL"上面加上 export NODE_HOME=/usr/local/bin/node-v10.15.3-linux-x64 export NODE_PATH=/usr/local/bin/node-v10.15.3-linux-x64/lib/node_modules export PATH=$PATH:$NODE_HOME/bin:$NODE_PATH #编译/etc/profile 使配置生效 source /etc

Is there a way to get puppeteer's waitUntil “networkidle” to only consider XHR (ajax) requests?

限于喜欢 提交于 2019-12-05 23:30:58
I am using puppeteer to evaluate the javascript-based HTML of web pages in my test app. This is the line I am using to make sure all the data is loaded: await page.setRequestInterception(true); page.on("request", (request) => { if (request.resourceType() === "image" || request.resourceType() === "font" || request.resourceType() === "media") { console.log("Request intercepted! ", request.url(), request.resourceType()); request.abort(); } else { request.continue(); } }); try { await page.goto(url, { waitUntil: ['networkidle0', 'load'], timeout: requestCounterMaxWaitMs }); } catch (e) { } Is this

node js puppeteer metadata

余生长醉 提交于 2019-12-05 21:41:42
I am new to Puppeteer, and I am trying to extract meta data from a Web site using Node.JS and Puppeteer. I just can't seem to get the syntax right. The code below works perfectly extracting the Title tag, using two different methods, as well as text from a paragraph tag. How would I extract the content text for the meta data with the name of "description" for example? meta name="description" content="Stack Overflow is the largest, etc" I would be seriously grateful for any suggestions! I can't seem to find any examples of this anywhere (5 hours of searching and code hacking later). My sample

Puppeteer: How to get the contents of each element of a nodelist?

China☆狼群 提交于 2019-12-05 16:38:28
I'm trying to achieve something very trivial: Get a list of elements, and then do something with the innerText of each element. const tweets = await page.$$('.tweet'); From what I can tell, this returns a nodelist, just like the document.querySelectorAll() method in the browser. How do I just loop over it and get what I need? I tried various stuff, like: [...tweets].forEach(tweet => { console.log(tweet.innerText) }); page.$$(): You can use a combination of elementHandle.getProperty() and jsHandle.jsonValue() to obtain the innerText from an ElementHandle obtained with page.$$() : const tweets =

Puppeteer confirm

≯℡__Kan透↙ 提交于 2019-12-05 16:33:11
I am trying to learn puppeteer. I have successfully scripted a login to a page and some navigation. Then I have it click on a button. The page throws up a window.confirm and I want my script to accept this to continue to the next step but I can’t figure out how. Can anyone point me in the right direction? Just done a simple test here, when a dialog box comes up on confirm. Simply pressing enter will close the dialog. So what we can do in puppeteer, is do exactly that. I knocked up a quick webpage that had a confirm box,.. eg. <div>Before confirm</div> <script> window.confirm("confirm");

How to make Puppeteer work with a ReactJS application on the client-side

三世轮回 提交于 2019-12-05 15:57:33
I am fairly new to React and I am developing an app which will take actual screenshots of a web page and the app can draw and add doodles on top of the screenshot taken. I initially used html2canvas and domToImage to take client-side screenshots but it doesn't render the image exactly as it is shown in the web page. Reddit user /pamblam0 suggested I look into Google's Puppeteer. How it works is that it launches a headless chromium browser which goes to my react app on localhost then gets a screenshot of that whole page easily. My problem however, is that puppeteer doesn't play nice inside a

Puppeteer - How to fill form that is inside an iframe?

早过忘川 提交于 2019-12-05 14:37:45
问题 I have to fill out a form that is inside an iframe, here the sample page. I cannot access by simply using page.focus() and page.type() . I tried to get the form iframe by using const formFrame = page.mainFrame().childFrames()[0] , which works but I cannot really interact with the form iframe. 回答1: Instead of figuring out how to get inside the iFrame and type, I would simplify the problem by navigating to the IFrame URL directly https://warranty.goodmanmfg.com/registration/NewRegistration