当前位置:网站首页>Puppeter connects to the existing Chrome browser
Puppeter connects to the existing Chrome browser
2022-07-06 22:34:00 【User 6256742】
Preface
Puppeteer It is a very popular headless browser and has received a lot recently star. The main function is to use and install Chromium Start a browser to simulate user operation , But this browser can be said to be one-time, unable to cache information , Many times we want to Puppeteer You can reuse locally launched browsers . After searching several articles, summarize the correct usage :
Use
1. In order to ensure a smooth link, we need to set Chrome The startup port of the browser
Right click the shortcut to set the content in the target : Add --remote-debugging-port=9222
2. Write program configuration puppeteer To configure
const axios = require('axios');
const puppeteer=require('puppeteer');
(async()=>{
let wsKey = await axios.get('http://localhost:9222/json/version');
let browser=await puppeteer.connect({
browserWSEndpoint: wsKey.data.webSocketDebuggerUrl,
defaultViewport:null
});
let page=await browser.newPage()
await page.goto('https://blogweb.cn');
// await page.close()
// await browser.disconnect()
})()
Explain
Use axios Get the corresponding link (http://localhost:9222/json/version) The communication configuration of is passed in puppeteer To configure ( The port number in the link needs to be and Chrome The port number in the target path corresponds to )
The following is the basic configuration of creating page scrolling and page Jump
summary
- modify Chrome Fixed port number
- In the configuration browser Request the corresponding connection before configuration webSocket To configure
- take webSocket Of key Put it into the corresponding configuration
边栏推荐
- void关键字
- MySQL教程的天花板,收藏好,慢慢看
- Build op-tee development environment based on qemuv8
- 金融人士必读书籍系列之六:权益投资(基于cfa考试内容大纲和框架)
- Heavyweight news | softing fg-200 has obtained China 3C explosion-proof certification to provide safety assurance for customers' on-site testing
- Senior soft test (Information System Project Manager) high frequency test site: project quality management
- 做接口测试都测什么?有哪些通用测试点?
- 关于声子和热输运计算中BORN电荷和non-analytic修正的问题
- 2022-07-05 stonedb的子查询处理解析耗时分析
- Spatial domain and frequency domain image compression of images
猜你喜欢
NPDP certification | how do product managers communicate across functions / teams?
基於 QEMUv8 搭建 OP-TEE 開發環境
NPDP认证|产品经理如何跨职能/跨团队沟通?
Export MySQL table data in pure mode
pytorch_ Yolox pruning [with code]
Mise en place d'un environnement de développement OP - tee basé sur qemuv8
The nearest common ancestor of binary (search) tree ●●
Aardio - 封装库时批量处理属性与回调函数的方法
config:invalid signature 解决办法和问题排查详解
(十八)LCD1602实验
随机推荐
Advantages of link local address in IPv6
空结构体多大?
case 关键字后面的值有什么要求吗?
【踩坑合辑】Attempting to deserialize object on CUDA device+buff/cache占用过高+pad_sequence
npm无法安装sharp
第3章:类的加载过程(类的生命周期)详解
ThreadLocal详解
Web APIs DOM time object
NPDP认证|产品经理如何跨职能/跨团队沟通?
0 basic learning C language - digital tube
3DMAX assign face map
config:invalid signature 解决办法和问题排查详解
MySQL教程的天花板,收藏好,慢慢看
做接口测试都测什么?有哪些通用测试点?
Plafond du tutoriel MySQL, bien collecté, regardez lentement
Aardio - 利用customPlus库+plus构造一个多按钮组件
HDR image reconstruction from a single exposure using deep CNN reading notes
如何实现文字动画效果
Applet system update prompt, and force the applet to restart and use the new version
Mise en place d'un environnement de développement OP - tee basé sur qemuv8