Puppeteer

How to set, change or block timezone(systemtime) with puppeteer?

纵饮孤独 提交于 2019-12-13 20:25:12
问题 OS: Windows 10 Pro x64-based PC node -v: v8.12.0 npm list puppeteer: `-- puppeteer@1.9.0 I tried this: puppeteer.launch({ env: { TZ: 'Australia/Melbourne', ...process.env } }); Dont work for me. whoer.net sees my actual systemtime. EDIT: Some information about https://github.com/nodejs/node/issues/4230 This code works well on Linux but does not work on windows. process.env.TZ = 'UTC'; console.log(new Date()); On windows i see timezone from my os. 回答1: To hide that info for all website, you

Error: Evaluation Failed: ReferenceError: util is not defined

半腔热情 提交于 2019-12-13 18:59:17
问题 I am trying to pass the util module object to puppeteer page.evaluate with no success. I understand this question was asked in How to pass required module object to puppeteer page.evaluate but the solution provided does not work in my case. MWE: const puppeteer = require("puppeteer"); const path = "http://books.toscrape.com/"; // scrape funs (async () =>{ const browser = await puppeteer.launch({headless: false}); const page = await browser.newPage(); await page.goto(path, {waitUntil:

鹿班|一人设计10亿图片,这个“设计师”如何演进?

佐手、 提交于 2019-12-13 10:46:37
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 本文内容提炼: 1、如何建立图片数据与用户注意力之间的连接? 2、如何进行结构化规模化的图片生产? 2019 年双十一期间,鹿班面向集团电商场景输送了 10亿 规模的图片。从提升公域流量效率,到商家私域的表达赋能,随着场景的细分,分人群精细化运营的需求提出,对图片结构化生产,规模化生产在量和质上的要求不断提高。图像生成技术也在不断的演进,本篇将围绕鹿班最近一年的在生成能力上演进以及实践做展开,欢迎探讨交流。 上图是我们有过采访的在平台上卖姜茶的店铺的图片运营经验,可以看到不同场景下的商品图文,在内容和形式是极具多样性,这种多样性不同于海量商品的个性化多样性,这种多样性是对 C 端用户注意力更加精细的吸引,这种多样性是对 B 端商家运营能力的一个新命题。 那么如何满足这种多样性生产?如何建立图片数据与用户注意力之间的连接?如何对商家赋能?下面我会从图片生产的视角切入,尝试回答以上问题。 生产标准-图片结构化 在 C 端的商品分发链路上,得益于结构化的标准定义,使得商品的数据和特征可以被高效的传递收集处理,从而给予模型和算法充分的施展空间。 当尝试将商品图片的数据作为一个整体进特征提取计算时,无论是低层次的显示特征还是高维的语义隐式特征在基于深度神经网络处理后都变成了一个概率问题

Uploading screenshot from AWS lambda to s3 bucket fails

家住魔仙堡 提交于 2019-12-13 06:19:40
问题 I am trying to take screenshots with puppeteer on aws lambda and upload the screenshot to a s3 bucket. However, the s3.putObject method doesn't seem to be working. On the lambda console, I got both the "uploading screenshot 's3://${s3bucket}/${filename}'" and "uploading completed" message but not the "inside callback" message. The weird thing is, I got no error during the lambda execution, but I just couldn't get the message inside the putObject method and couldn't find the screenshots in the

How to use puppeteer to turn Chromium on in mobile debug mode?

梦想与她 提交于 2019-12-13 04:18:13
问题 I want to start Chrome with puppeteer, and in mobile debug mode, It means to click the 'toggle device toolbar' button in devtools. Sorry, I don't have enough prestige to upload pictures. I tried the following code but it didn't work: const browser = await puppeteer.launch({ devtools: true, ignoreHTTPSErrors: true, isMobile:true //I thought it would be fine to set isMobile: true, but not }); So what should I do? 回答1: The isMobile property is a part of the defaultViewport object, it means that

How to use puppeteer to automante Amazon Connect CCP login?

不羁的心 提交于 2019-12-13 03:53:12
问题 I'm trying use puppeteer to automate the login process for our agents in Amazon Connect however I can't get puppeteer to finish loading the CCP login page. See code below: const browser = await puppeteer.launch(); const page = await browser.newPage(); const url = 'https://ccalderon-reinvent.awsapps.com/connect/ccp#/'; await page.goto(url, {waitUntil: 'domcontentloaded'}); console.log(await page.content()); // console.log('waiting for username input'); // await page.waitForSelector('#wdc

How can I consistently fill out input fields?

一世执手 提交于 2019-12-13 03:42:25
问题 I'm not sure why, but it seems like some fields just don't work for me. This is working fine for me on one site: await page.click(USERNAME_SELECTOR); await page.keyboard.type(CREDS.username); await page.click(PASSWORD_SELECTOR); await page.keyboard.type(CREDS.password); await page.click(LOGIN_BUTTON_SELECTOR); await page.waitForNavigation(); However, on https://app.member.virginpulse.com/, it doesn't seem to work for me. It should be simple enough as the input fields both have IDs ( #username

Intercept and mock WebSockets request/responses with pupeteer

核能气质少年 提交于 2019-12-13 03:14:10
问题 Is there a way to intercept and mock WebSockets requests/responses with puppeteer? page.on('request', request => { console.log('Intercepting Request ', request, { depth: null }); request.continue(); }); page.on('response', response => { console.log('Intercepting Response ', response, { depth: null }); response.abort(); }); does not show the requests/responses made through WebSocket. This How to use puppeteer to dump WebSocket data is answering the question somewhat, but not by using puppeteer

UnhandledPromiseRejectionWarning: Error: Protocol error (Runtime.callFunctionOn): Target closed. (Puppeteer)

99封情书 提交于 2019-12-13 02:53:43
问题 I am new to Puppeteer and Node and I get this error when trying to execute the following code: 'use strict'; const puppeteer = require('puppeteer'); const evalLib = require('./oaa_a11y_evaluation.js'); function evaluateRules() { var ruleset = OpenAjax.a11y.RulesetManager.getRuleset("ARIA_STRICT"); var evaluator_factory = OpenAjax.a11y.EvaluatorFactory.newInstance(); evaluator_factory.setParameter('ruleset', ruleset); evaluator_factory.setFeature('eventProcessing', 'fae-util'); evaluator

Puppeteer screenshot has missing/invisible text

眉间皱痕 提交于 2019-12-13 02:50:22
问题 I'm using puppeteer to save and download images from markup & css sent to an express app by the browser. Express compiles the template, just inserting the POSTed markup into an html shell & gets the css locally (mounted on a docker volume). When I render the html & css directly in chrome, all text and other elements display as expected. The screenshot that is saved, however, is missing the text. When I leave out our styles, the text renders the same way in both local chrome & the image saved