当前位置:网站首页>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
边栏推荐
- extern关键字
- Web APIs DOM 时间对象
- 0 basic learning C language - interrupt
- 12、 Start process
- SQL server generates auto increment sequence number
- Unity3d minigame unity webgl transform plug-in converts wechat games to use dlopen, you need to use embedded 's problem
- The nearest common ancestor of binary (search) tree ●●
- 关于声子和热输运计算中BORN电荷和non-analytic修正的问题
- 【雅思口语】安娜口语学习记录part1
- Adavit -- dynamic network with adaptive selection of computing structure
猜你喜欢
在IPv6中 链路本地地址的优势
(十八)LCD1602实验
基於 QEMUv8 搭建 OP-TEE 開發環境
视图(view)
Export MySQL table data in pure mode
How to confirm the storage mode of the current system by program?
[leetcode] 19. Delete the penultimate node of the linked list
Web APIs DOM 时间对象
Unity3d minigame unity webgl transform plug-in converts wechat games to use dlopen, you need to use embedded 's problem
[Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation
随机推荐
SQL Server生成自增序号
Void keyword
What are the specific steps and schedule of IELTS speaking?
软考高级(信息系统项目管理师)高频考点:项目质量管理
OpenCV VideoCapture. Get() parameter details
MySQL数据库基本操作-DML
Pit encountered by handwritten ABA
NetXpert XG2帮您解决“布线安装与维护”难题
变量与“零值”的比较
Netxpert xg2 helps you solve the problem of "Cabling installation and maintenance"
Anaconda installs third-party packages
Plafond du tutoriel MySQL, bien collecté, regardez lentement
BasicVSR_PlusPlus-master测试视频、图片
MySQL ---- first acquaintance with MySQL
如何用程序确认当前系统的存储模式?
TypeScript获取函数参数类型
Return keyword
Should novice programmers memorize code?
China 1,4-cyclohexanedimethanol (CHDM) industry research and investment decision-making report (2022 Edition)
树的先序中序后序遍历