[python] python+selenium+webdriver
Posted buptqq
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[python] python+selenium+webdriver相关的知识,希望对你有一定的参考价值。
1. install python, set environment variables.
2. pip install selenium
3. 下载与自己浏览器版本匹配的chrome webdriver, 放到python.exe同目录(python安装目录)。
http://npm.taobao.org/mirrors/chromedriver/
http://chromedriver.storage.googleapis.com/index.html
4. call webdriver.
>>> import selenium
>>> from selenium import webdriver
>>> browser=webdriver.Chrome()
DevTools listening on ws://127.0.0.1:55004/devtools/browser/c87418a6-14a3-4054-86d0-700674958922
[6520:20152:0604/123552.662:ERROR:device_event_log_impl.cc(208)] [12:35:52.662] Bluetooth: bluetooth_adapter_winrt.cc:1191 Getting Radio failed. Chrome will be unable to change the power state by itself.
[6520:20152:0604/123552.721:ERROR:device_event_log_impl.cc(208)] [12:35:52.720] Bluetooth: bluetooth_adapter_winrt.cc:1269 OnPoweredRadioAdded(), Number of Powered Radios: 1
[6520:20152:0604/123552.722:ERROR:device_event_log_impl.cc(208)] [12:35:52.722] Bluetooth: bluetooth_adapter_winrt.cc:1284 OnPoweredRadiosEnumerated(), Number of Powered Radios: 1
>>> browser.get("http://www.baidu.com")
>>> browser.find_element_by_id(‘kw‘).send_keys(‘hello world‘)
>>> browser.find_element_by_id(‘su‘).click()
>>> browser.close()
以上是关于[python] python+selenium+webdriver的主要内容,如果未能解决你的问题,请参考以下文章
selenium ide和selenium python的区别