selenium python 启动Chrome

启动Chrom浏览器

下载chromedriver:

http://chromedriver.storage.googleapis.com/index.html

当时找chromedriver与chrome的的对应版本的好麻烦,如今整理下:

selenium python 启动Chrome

驱动的下载地址如下:
http://chromedriver.storage.googleapis.com/index.html

我下载的是2.29,对应的Chrome浏览器下载的下图中绿色标记的那个,下载完后将exe文件放在“C:\Users\Administrator\AppData\Local\Google\Chrome\Application”路径下,即Chrome快捷方式的路径下

然后将上面的路径添加到path中

下载浏览器:https://www.chromedownloads.net/chrome32win-stable/

selenium python 启动Chrome

以上设置完毕后PyCharm运行时还是报莫名其妙的错误,这时重启PyCharm,OK了

以下是模拟登录京东商城签到的,可惜点登录时要输入图形验证码,卡在这里、、、

 import time

 from selenium import webdriver
import os username = "jiangpr_ok@163.com" # 请替换成你的用户名
password = "d123456789d" # 请替换成你的密码 driver = webdriver.Chrome() # 选择Chrome浏览器
# driver = webdriver.Firefox()
driver.get(url='http://vip.jd.com') # 打开京东会员网站
time.sleep(1) driver.find_element_by_link_text('账户登录').click()
driver.find_element_by_id('loginname').click()
driver.find_element_by_id('loginname').send_keys(username)
driver.find_element_by_id('nloginpwd').click()
driver.find_element_by_id('nloginpwd').send_keys(password) driver.find_element_by_id('loginsubmit').click()
time.sleep(1)
driver.find_element_by_id('signIn').click()
driver.close()
上一篇:阿里巴巴分布式服务框架 Dubbo


下一篇:React获得真实的DOM操作