当前位置:网站首页>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
边栏推荐
- 【无标题】
- CCNA Cisco network EIGRP protocol
- CocosCreator+TypeScripts自己写一个对象池
- 雅思口语的具体步骤和时间安排是什么样的?
- UDP programming
- 机试刷题1
- uniapp滑动到一定的高度后固定某个元素到顶部效果demo(整理)
- The nearest common ancestor of binary (search) tree ●●
- Chapter 3: detailed explanation of class loading process (class life cycle)
- Netxpert xg2 helps you solve the problem of "Cabling installation and maintenance"
猜你喜欢

软考高级(信息系统项目管理师)高频考点:项目质量管理
![pytorch_ Yolox pruning [with code]](/img/98/31d6258635ce48ac53819d0ca12d1d.jpg)
pytorch_ Yolox pruning [with code]

Netxpert xg2 helps you solve the problem of "Cabling installation and maintenance"

0 basic learning C language - digital tube

HDR image reconstruction from a single exposure using deep CNN reading notes

(18) LCD1602 experiment
The SQL response is slow. What are your troubleshooting ideas?
![[Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation](/img/2b/15b3d831bba6aa772ad83f3ac91d23.png)
[Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation

如何用程序确认当前系统的存储模式?

Aardio - 封装库时批量处理属性与回调函数的方法
随机推荐
The SQL response is slow. What are your troubleshooting ideas?
POJ 1258 Agri-Net
2022-07-04 mysql的高性能数据库引擎stonedb在centos7.9编译及运行
0 basic learning C language - digital tube
leetcode:面试题 17.24. 子矩阵最大累加和(待研究)
Sword finger offer question brushing record 1
void关键字
变量与“零值”的比较
Const keyword
Aardio - 封装库时批量处理属性与回调函数的方法
What are the interface tests? What are the general test points?
i. Mx6ull build boa server details and some of the problems encountered
Unity3d minigame-unity-webgl-transform插件转换微信小游戏报错To use dlopen, you need to use Emscripten‘s...问题
剪映+json解析将视频中的声音转换成文本
Config:invalid signature solution and troubleshooting details
【数字IC手撕代码】Verilog无毛刺时钟切换电路|题目|原理|设计|仿真
OpenNMS分离数据库
项目复盘模板
Mysql database basic operations DML
[leetcode] 19. Delete the penultimate node of the linked list