Puppeteer

Puppeteer get 3rd party cookies

那年仲夏 提交于 2020-01-02 04:34:09
问题 How can I get 3rd party cookies from website using puppeteer? For first party I know I can use await page.cookies() 回答1: I was interested to know the answer so have found a solution too, it works for the current versions of Chromium 75.0.3765.0 and puppeteer 1.15.0 (updated May 2nd 2019) . Using internal puppeteer page._client methods we can make use of Chrome DevTools Protocol directly: (async() => { const browser = await puppeteer.launch({}); const page = await browser.newPage(); await page

How to use proxy in puppeteer and headless Chrome?

假装没事ソ 提交于 2020-01-01 02:47:08
问题 Please tell me how to properly use a proxy with a puppeteer and headless Chrome. My option does not work. const puppeteer = require('puppeteer'); (async () => { const argv = require('minimist')(process.argv.slice(2)); const browser = await puppeteer.launch({args: ["--proxy-server =${argv.proxy}","--no-sandbox", "--disable-setuid-sandbox"]}); const page = await browser.newPage(); await page.setJavaScriptEnabled(false); await page.setUserAgent(argv.agent); await page.setDefaultNavigationTimeout

Puppeteer: How to submit a form?

人盡茶涼 提交于 2020-01-01 01:58:10
问题 Using puppeteer, how could you programmatically submit a form? So far I've been able to do this using page.click('.input[type="submit"]') if the form actually includes a submit input. But for forms that don't include a submit input, focusing on the form text input element and using page.press('Enter') doesn't seem to actually cause the form to submit: const puppeteer = require('puppeteer'); (async() => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await

puppeteer-web: “Puppeteer is not a constructor”

南笙酒味 提交于 2019-12-31 05:03:34
问题 I'm trying to follow the instructions here to bundle puppeteer, with the intention of including it in a chrome extension as a hacky way of scripting operations in the browser window (specifically, printing a page to PDF, which is surprisingly impossible with just the Chrome Extension API as far as I can tell). As per the README in the link above, I've set up my Chrome extension as follows: background.html <script src="./puppeteer/utils/browser/puppeteer-web.js"></script> <script src=

Promise.all error inside async function : undefined is not a function

大憨熊 提交于 2019-12-31 03:58:10
问题 in my async function i use Promise.all but for some reason its not defined or something here is the function async function check_available_money() { global_browser = await puppeteer.launch({headless: false, args: ['--no-sandbox', '--disable-setuid-sandbox']}); const page = await global_browser.newPage(); await page.setViewport({width: 1000, height: 1100}); var setting = {'username': 'aa', 'password': 'bb'}; try { await page.goto('https://example.com/login', {timeout: 90000}) .catch(function

inject jquery into puppeteer page

两盒软妹~` 提交于 2019-12-29 18:42:10
问题 I'm trying to inject jquery into my puppeteer page because document.querySelector doesn't cut it for me: async function inject_jquery(page){ await page.evaluate(() => { var jq = document.createElement("script") jq.src = "https://code.jquery.com/jquery-3.2.1.min.js" document.querySelector("head").appendChild(jq) }) const watchDog = page.waitForFunction('window.jQuery !== undefined'); await watchDog; } The result is it mostly times out. Does anyone have a solution? 回答1: I have used page

轻松搭建基于 Serverless 的文档图片在线转换服务

主宰稳场 提交于 2019-12-26 11:02:47
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 核心优势 异构服务:支持多种运行环境 用于媒体文件转换的库或者二进制往往和业务的运行环境不同,对计算资源的需求也有较大的差异。 函数计算支持多种运行环境,支持为独立的转换函数定制算力单位,根据请求量自动伸缩,让核心业务和支持业务做到较好的分离。 灵活触发:支持多种触发方式 函数计算既可以通过集成事件源服务(OSS、API 网关、日志服务和表格存储)产生事件来触发函数执行,也可以通过 HTTP 触发器使用 HTTP 请求触发函数执行,还支持 API/SDK 直接调用函数。 弹性伸缩: 轻松应对负载的波峰波谷 函数计算提供跨可用区的容灾能力,根据请求量自动进行毫秒级弹性扩容,快速调度计算资源,轻松应对业务洪峰。 预留实例功能彻底消除实例冷启动带来的延时毛刺,为在线应用迁移至函数计算扫清障碍! 工程效率:搭建速度快,运维代价小 使用函数计算,开发者无需管理服务器等基础设施,只需编写并上传代码,函数计算准备好计算资源,弹性可靠地运行任务,并提供完备的日志与监控报警服务,帮助服务快速上线且免除繁琐的运维操作。 最佳实践 快速开发一个分布式 Puppeteer 网页截图服务 示例搭建了一个具备弹性的 Puppeteer 网页截图服务,实现的功能为:客户端将想要截图的网页地址发送给函数,函数负责渲染网页内容,并截图返回。

Page Object Model structure for a complex application

允我心安 提交于 2019-12-25 01:48:25
问题 I've in the past couple of months used Puppeteer to drive an automation for a couple of small level projects. Now I want to scale the framework for a medium/large complex application. I want to use the famed Page Object Model, where in I have separated the locators, page methods in separate files and I'm calling them in the corresponding page execution code. My directory structure is like this e2e_tests - locators - common-locators.js - page1locators.js - page2locators.js - constants - config

Puppeteer opening chrome instance for each file at once

夙愿已清 提交于 2019-12-25 00:38:38
问题 I am trying to automate a workflow in which I have a list of files from a directory and I put them in an array. Then for each file in array I call a function for Chrome automation. const path = require('path'); const chalk = require('chalk'); const puppeteer = require('puppeteer'); module.exports = { generateOutput : async(fileName, url = "https://example.com/") => { const filePath = path.join(process.cwd(), fileName); const outputFilePath = path.join(process.cwd(), "OutputFiles"); try{ const

Puppeteer Throwing Invalid Parameters Error

六眼飞鱼酱① 提交于 2019-12-25 00:12:19
问题 I am trying to convert an HTML content to PDF, but I am getting Invalid parameters for scale and preferCSSPageSize when passed using variables. Error Message: Error: Protocol error (Page.printToPDF): Invalid parameters scale: double value expected; preferCSSPageSize: boolean value expected at Promise (/home/santhosh-4759/Downloads/node-v8.11.3-linux-x64/bin/node_modules/puppeteer/lib/Connection.js:202:56) at new Promise () Command Used: ./node puppeteerpdf.js test.pdf 1 false '' '' false