在用一台新设备操纵selenium模拟浏览器时:
设备条件:安装Anaconda(或Python),配置有WLAN(以及vpn)。
pip install -U selenium
from selenium import webdriver
第一步:配置Webdriver
在谷歌浏览器直接搜索 chrome://version/ 查看浏览器版本。
在这个地址 :http://chromedriver.storage.googleapis.com/index.html 下载与浏览器版本相匹配的driver。
手动将webdriver放在python运行路径下,以及浏览器路径下。
#anaconda路径:
/opt/anaconda3/bin/
C:\Users\Administrator\anaconda3\Scripts\
#浏览器可执行文件路径:
/Applications/Google Chrome.app/Contents/MacOS/ #具体参考浏览器版本的说明
第二步:配置Tmp文件(选择)
找到浏览器版本页面的个人资料文件,创建空的.tmp文件。
option = webdriver.ChromeOptions()
option.add_argument(r"user-data-dir=配置文件路径")
driver = webdriver.Chrome(executable_path = '/opt/anaconda3/bin/chromedriver',options=option)
配置文件可以缓存登录信息,每开启一个新的模拟浏览器,通过上述代码手动登入账号(或通过代码自动登入)。之后不用重复登录即可爬取文章内容。注意:浏览器设置不要清除缓存。
行动吧,在路上总比一直观望的要好,未来的你肯定会感谢现在拼搏的自己!如果想学习提升找不到资料,没人答疑解惑时,请及时加入群: 759968159,里面有各种测试开发资料和技术可以一起交流哦。
最后: 下方这份完整的软件测试视频教程已经整理上传完成,需要的朋友们可以自行领取【保证100%免费】
软件测试面试文档
我们学习必然是为了找到高薪的工作,下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料,并且有字节大佬给出了权威的解答,刷完这一套面试资料相信大家都能找到满意的工作。