这篇文章上次修改于 789 天前,可能其部分内容已经发生变化,如有疑问可询问作者。
本次实战主要实现功能为chrome 的复用,cookie 导入实现登陆,利用selenium 实现浏览器控制。
selenium 安装
pip install selenium
下载chrome 驱动并配置环境变量
chrome 复用
配置chrome 环境变量,方便打开调试端口
#将"Google\ Chrome"添加到环境变量中 export PATH="/Applications/Google Chrome.app/Contents/MacOS":$PATH #给命令"Google\ Chrome"起别名chrome alias chrome="Google\ Chrome"
命令行打开调试
chrome --remote-debugging-port=9222
写代码实现需求
本文代码地址:github点击这里 gitlab点击这里 gitee点击这里