[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()

相关推荐