zoukankan      html  css  js  c++  java
  • selenium python 启动Chrome

    启动Chrom浏览器

    下载chromedriver:

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

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

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

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

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

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

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

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

     1 import time
     2 
     3 from selenium import webdriver
     4 import os
     5 
     6 username = "jiangpr_ok@163.com" # 请替换成你的用户名
     7 password = "d123456789d" # 请替换成你的密码
     8 
     9 driver = webdriver.Chrome() # 选择Chrome浏览器
    10 # driver = webdriver.Firefox()
    11 driver.get(url='http://vip.jd.com') # 打开京东会员网站
    12 time.sleep(1)
    13 
    14 
    15 driver.find_element_by_link_text('账户登录').click()
    16 driver.find_element_by_id('loginname').click()
    17 driver.find_element_by_id('loginname').send_keys(username)
    18 driver.find_element_by_id('nloginpwd').click()
    19 driver.find_element_by_id('nloginpwd').send_keys(password)
    20 
    21 driver.find_element_by_id('loginsubmit').click()
    22 time.sleep(1)
    23 driver.find_element_by_id('signIn').click()
    24 driver.close()
  • 相关阅读:
    【模板】Sparse-Table
    UVa 11235 Frequent values
    【模板】树状数组
    UVa 1428 Ping pong
    数学技巧
    UVa 11300 Spreading the Wealth
    UVa 11729 Commando War
    UVa 11292 Dragon of Loowater
    POJ 3627 Bookshelf
    POJ 1056 IMMEDIATE DECODABILITY
  • 原文地址:https://www.cnblogs.com/jpr-ok/p/9261798.html
Copyright © 2011-2022 走看看