Puppeteer

puppeteer: Getting HTML from NodeList?

≯℡__Kan透↙ 提交于 2020-12-26 09:12:36
问题 I'm getting a list of 30 items from the code: const boxes = await page.evaluate(() => { return document.querySelectorAll("DIV.a-row.dealContainer.dealTile") }) console.log(boxes); The result { '0': {}, '1': {}, '2': {}, .... '28': {}, '29': {} } I have the need to see the html of the elements. But every property I tried of boxes is simply undefined . I tried length , innerHTML , 'innerText` and some other. I am sure of box really containing something because puppeteer's screenshot shows the

puppeteer: Getting HTML from NodeList?

╄→尐↘猪︶ㄣ 提交于 2020-12-26 09:07:38
问题 I'm getting a list of 30 items from the code: const boxes = await page.evaluate(() => { return document.querySelectorAll("DIV.a-row.dealContainer.dealTile") }) console.log(boxes); The result { '0': {}, '1': {}, '2': {}, .... '28': {}, '29': {} } I have the need to see the html of the elements. But every property I tried of boxes is simply undefined . I tried length , innerHTML , 'innerText` and some other. I am sure of box really containing something because puppeteer's screenshot shows the

前端骨架屏

戏子无情 提交于 2020-12-24 19:04:08
骨架屏 最近在项目不时有用到骨架屏的需求,所以抽时间对骨架屏的方案作了一下调研,骨架屏的实践已经有很多了,也有很多人对自己的方案作了介绍.在这里按照个人的理解做了一个汇总和分类,分享给大家. 关于骨架屏(简介) 骨架屏就是在页面数据尚未加载前先给用户展示出页面的大致结构,直到请求数据返回后再渲染页面,补充进需要显示的数据内容。常用于文章列表、动态列表页等相对比较规则的列表页面。 很多项目中都有应用:ex:饿了么h5版本,知乎,facebook等网站中都有应用。 借个图举例如下: 两类用途 简介中作了关于用途的说明,但是仍然可以继续细分: 作为spa中路由切换的loading,结合组件的生命周期和ajax请求返回的时机来使用. 作为首屏渲染的优化. 第一类用途 第一类用途需要自己编写骨架屏,推荐两个成熟方便定制的svg组件定制为骨架屏的方案 react-content-loader vue-content-loader 作为首屏渲染(自动化方案) 该方案是饿了么在骨架屏的实践中总结出的一套方案: 骨架屏的dom结构和css通过离线生成后构建的时候注入模板中的节点下面. 原理相关 eleme骨架屏插件实现原理 方案的项目地址: page-skeleton-webpack-plugin 使用时候的注意点: cssUnit的配置: 需要使用自适应的单位,按照文档给出的选择范围选,直接用

Puppeteer学习笔记 (2)- Puppeteer的安装

青春壹個敷衍的年華 提交于 2020-12-17 15:51:49
本文链接: https://www.cnblogs.com/hchengmx/p/11009849.html 1. <a name = "node的下载安装">node的下载安装</a> 由于puppeteer是nodejs的一个库,所以首先需要安装nodejs。 下载地址: https://nodejs.org/zh-cn/ 我在这里用的是长期支持版,10.16.0。 下载后一路安装 安装成功后,需要检测node和npm有无安装成功,正确的话会出现node和npm的版本号。 node -v note: 要是失败了,就需要检查环境变量是是否有nodejs的路径。 安装成功后nodejs文件夹下内容如下。 2. <a name = "node的安装模块路径配置">node的安装模块路径配置</a> 之所以要配置安装模块路径,是因为要是不配置,以后下载的模块都会放在 C:\\Users\\用户名\\AppData\\Roaming\\npm" 和 C:\\Users\\chenghang\\AppData\\Roaming\\npm-cache 这样的路径下,不太方便查找自己安装的模块,我们希望所有的模块都安装在 C:\Program Files\nodejs\ 路径下。 首先C:\Program Files\nodejs\ 下创建两个文件夹,node_cache 和 node

Is there any way I can execute my node js and puppeteer program with an exe file?

纵饮孤独 提交于 2020-12-15 07:18:28
问题 This program works well on puppeteer when i use it on CMD. Although, it is a lengthy process and also complicated for any non-technical person. I want to make an exe file that perform the task I do manually to run this node.js file in CMD. As you can see first my program will open the browser and goto a (URL). I want to make different program with different URL. So that, if a person want to run this code, he just click the exe file and then that software will automatically do that task for

Puppeteer does not change selector

随声附和 提交于 2020-12-14 06:53:08
问题 I'm trying to automate the task of querying for data on this site using Puppeteer. So I need to select the dataset (Daily Summaries, 1st option), then select location type (State, 3rd option), then select state (Alaska, 2nd option). The problem is my code does not change to the next table. So instead of selecting the 3rd option (State) after selecting the 1st option in dataset (Daily Summaries), it just selects the 3rd option but in dataset table again! I am new to Puppeteer so I don't really

Puppeteer does not change selector

别说谁变了你拦得住时间么 提交于 2020-12-14 06:50:13
问题 I'm trying to automate the task of querying for data on this site using Puppeteer. So I need to select the dataset (Daily Summaries, 1st option), then select location type (State, 3rd option), then select state (Alaska, 2nd option). The problem is my code does not change to the next table. So instead of selecting the 3rd option (State) after selecting the 1st option in dataset (Daily Summaries), it just selects the 3rd option but in dataset table again! I am new to Puppeteer so I don't really

Puppeteer intercept request and respond in json

不羁岁月 提交于 2020-12-13 17:51:51
问题 So puppeteer provide pretty basic example of intercepting a request for a url to a pic, and responding with a different url to a different pic. Example from their doc here: https://github.com/webdriverio/webdriverio/tree/master/packages/devtools My question is I'm trying to intercept an XHR request and respond with my own json. I can't seem to find the documentation on this. It would be nice if someone can share where more documentation on this can be. Or provide examples of this. I want to

Puppeteer intercept request and respond in json

偶尔善良 提交于 2020-12-13 17:46:51
问题 So puppeteer provide pretty basic example of intercepting a request for a url to a pic, and responding with a different url to a different pic. Example from their doc here: https://github.com/webdriverio/webdriverio/tree/master/packages/devtools My question is I'm trying to intercept an XHR request and respond with my own json. I can't seem to find the documentation on this. It would be nice if someone can share where more documentation on this can be. Or provide examples of this. I want to

Puppeteer intercept request and respond in json

末鹿安然 提交于 2020-12-13 17:44:53
问题 So puppeteer provide pretty basic example of intercepting a request for a url to a pic, and responding with a different url to a different pic. Example from their doc here: https://github.com/webdriverio/webdriverio/tree/master/packages/devtools My question is I'm trying to intercept an XHR request and respond with my own json. I can't seem to find the documentation on this. It would be nice if someone can share where more documentation on this can be. Or provide examples of this. I want to