初涉selenium+phantomjs
来源:互联网 发布:嵌入式linux开发前景 编辑:程序博客网 时间:2024/06/03 03:21
selenium github 地址
selenium api,这里可以看到源代码
可以参考这位大神的博客
这三个包提供了基础支持:
common,support,remote
其他几个是对各个浏览器驱动封装的调用接口:
chrome,firefox,phantomjs等
selenium.webdriver.remote.webdriver.WebDriver提供了driver的实现,chrome,firefox,phantomjs包下的driver都继承这个实现
接下来主要研究几个基础包和phantomjs:
driver.execute_script(“return navigator.userAgent”)获取当前浏览器
phantomjs的默认浏览器ua:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1
发生异常时停止加载当前页面:
IE浏览器用document.execCommand(“Stop”),
Chrome和Firefox用window.stop()
driver.execute_script(‘window.stop’)
driver.back(),driver.forward()可以向后向前跳转,是不是维护了一个通过新窗口获取的url的有序集合?
driver.add_cookie(dict):这个方法复制上一个请求的cookie,会出现一个错误:Can only set Cookies for the current domain
解决:
desc = webdriver.DesiredCapabilities.PHANTOMJS.copy()
desc[…]=…(其他设置)
cookies = driver.get_cookies()
driver.start_session(desc)
for cookie in cookies:
try:
driver.add_cookie(cookie)
except Exception as e:
print(repr(e)
这样处理后居然前后driver的cookie是一样的,达到复制cookie的目的,这让我没搞清楚它为什么会报错?!
一时理解,请不吝指正!
- 初涉selenium+phantomjs
- selenium phantomjs
- selenium+phantomjs
- Selenium+phantomJS
- phantomjs + selenium headless test
- selenium + PhantomJS 操作
- 爬虫利器:Selenium+PhantomJS
- 使用selenium+phantomjs
- phantomjs+selenium+python爬虫
- Scrapy+Selenium+Phantomjs Demo
- python+selenium+phantomjs 踩坑
- Selenium + phantomjs使用总结
- python selenium phantomjs学习
- 安装Selenium&PhantomJS
- 爬虫-08-selenium & phantomjs
- Python3+phantomjs+selenium配置
- Selenium 与PhantomJS
- Selenium和PhantomJS介绍
- Ubuntu里权限相关问题
- xStream完美转换XML、JSON xStream框架 xStream可以轻易的将Java对象和xml文档相互转换,而且可以修改某个特定的属性和节点名称,而且也支持json的转换; 前面有介
- OpenStack公共组件oslo之七——oslo.middleware
- URL编码
- 机器学习实战-logistic回归随机梯度上升浅见
- 初涉selenium+phantomjs
- Oracle之SQL语句性能优化(34条优化方法)
- 关于使用xpath的疑惑
- [Android N]KeyStore mBinder成员空指针引起system process不断重启
- 通过Synplify Pro查看FSM状态机
- SQL语句大全
- VS IntelliSense不识别新安装的Python库解决方法
- IDEA 热部署 Tomcat
- COOP绕过微软最新CFG(Control Flow Guard)