第一步, 启动已安装好的Chrome 浏览器
// for mac "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --remote-debugging-port=9222 --no-first-run --no-default-browser-check --user-data-dir=$(mktemp -d -t 'chrome-remote_data_dir')
// for windows 文件路径/chrome.exe --remote-debugging-port=9222
第二部,在浏览器中请求地址:是正常的GET请求,获得到webSocketDebuggerUrl参数。
http://localhost:9222/json/version
第三步,连接websocket
const browser = await puppeteer.connect({ browserWSEndpoint: webSocketDebuggerUrl });