selenium--环境搭建

1、安装selenium库:pip install selenium

2、安装google浏览器

3、根据不同的google浏览器版本下载对应的chromedriver驱动,win32也能在64位上运行

驱动下载地址:https://sites.google.com/a/chromium.org/chromedriver/或者

https://chromedriver.storage.googleapis.com/index.html或者

http://npm.taobao.org/mirrors/chromedriver/

版本对应关系:http://blog.csdn.net/huilan_same/article/details/51896672

4、把下载的chromedriver.exe

5、把chromedriver.exe所在的文件夹加入环境变量里(调用webdriver.Chrome()时不需要写路径)

 

from selenium import webdriver
driver=webdriver.Chrome()    #这里的Chrome的C为大写
driver.implicitly_wait(10)
driver.get('http://www.baidu.com')    #地址需要全的,带http的
assert '百度' in driver.title
driver.quit()

 

posted @ 2020-06-24 23:14  追逐蹉跎的岁月  阅读(110)  评论(0)    收藏  举报