Puppeteer

Puppeteer custom header footer for PDF render

拜拜、爱过 提交于 2019-12-24 00:21:11
问题 I am working on rendering a PDF of a site. I want different headers and footers for the first page and different for the rest of the pages. Is there any way to do this? const puppeteer = require('puppeteer'); (async() => { var t = Date.now(); console.log('Current time ' + t + ' msec'); const browser = await puppeteer.launch({executablePath: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe', ignoreHTTPSErrors:true, headless:true, devtools:false}); const page = await browser

Node.js puppeteer - Fetching content seperated by br and store items in seperate variables

不想你离开。 提交于 2019-12-23 23:11:59
问题 I'm using node.js and puppeteer to get some data. How can I save the content of an element (which is divided by line break <br> ) in two separate variables? That's the HTML I'm looking at: <table summary=""> <tbody> <tr nowrap="nowrap" valign="top" align="left"> <td nowrap="nowrap">2018-08-14<br>16:35:41</td> </tr> </tbody> </table> I'm getting the content of the td like this (app.js): let tableCell04; let accepted; tableCell04 = await page.$( 'body div table tr td' ); accepted = await page

Selecting href attributers with Puppeteer

扶醉桌前 提交于 2019-12-23 20:43:21
问题 I am trying to extract a few urls from this page with Puppeteer. However all my script is returning is undefined const puppeteer = require('puppeteer'); async function run() { const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']}); const page = await browser.newPage(); await page.goto('https://divisare.com/'); let projects = await page.evaluate((sel) => { return document.getElementsByClassName(sel) }, 'homepage-project-image'); var aNode = projects[0]

running puppeteer code in firebase cloud functions

烈酒焚心 提交于 2019-12-23 18:17:50
问题 I'm working on a personal project which is an app where an user can input their address & credit card info and click a button to buy a parking permit for one of the university that I visit often. I want to host my front end in firebase's cloud storage and I want to create a cloud function where puppeteer code can run with the information that I save to the firebase's realtime database. Is it possible for firebase cloud function to run puppeteer code that buy a parking permit? Since puppeteer

I need more info about Puppeteer page.metrics and queryObjects

▼魔方 西西 提交于 2019-12-23 12:54:45
问题 I'm using Puppeteer to find a memory leak issue. I'm using puppeteer's page.metrics() API but I am having trouble understanding each properties meaning. All my values in the metrics keep increasing in value over time. Is this expected? Or is this an indication that there might be a serious memory leak? The properties which are growing in value as the app runs are: JSEventListeners, Nodes, LayoutCount, RecalcStyleCount, LayoutDuration, RecalcStyleDuration, ScriptDuration, TaskDuration,

In Puppeteer how to switch to chrome window from default profile to desired profile

让人想犯罪 __ 提交于 2019-12-23 12:27:54
问题 My requirement is to test chrome extensions on a new profile. I referred https://peter.sh/experiments/chromium-command-line-switches/ for Chromium args[--user-data-dir, --profile-directory] After the browser is launched, 2 chrome windows are opened. One with given profile and extension and another with default profile and given extension. Also the focus is on a window with default profile. So all actions are happening on it. I had expected that only 1 browser window would be opened with

Puppeteer-web: Protocol error (Target: getBrowserContexts) not allowed

折月煮酒 提交于 2019-12-23 02:34:15
问题 I've got a chrome extension that is trying to implement puppeteer-web. I've followed the following code to try and get set up puppeteer-web: "Puppeteer is not a constructor" This is my code: const puppeteer = require("puppeteer"); async function initiatePuppeteer() { let browserWSEndpoint = ''; await fetch("http://127.0.0.1:9222/json") .then(response => response.json()) .then(function(data) { let filteredData = data.filter(tab => tab.type ==='page'); browserWSEndpoint = filteredData[0]

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

僤鯓⒐⒋嵵緔 提交于 2019-12-22 10:58:16
问题 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

Nodejs/Puppeteer - How to use page.evaluate

烂漫一生 提交于 2019-12-22 09:57:50
问题 I know is a noob question, but I want to know when I should use page.evaluate I also know the documentation exists, but I still do not understand Can anybody give me an explanation about how and when to use this function when creating a scraper with puppeteer? 回答1: First, it is important to understand that there are two main environments: Node.js (Puppeteer) Environment Page DOM Environment You should use page.evaluate() when you are seeking to interact with the page directly in the page DOM