search

Home  >  Q&A  >  body text

python+webdriver想登录淘宝,输入用户名密码点登录后,提示请输入验证码,然后怎么解决?

# -*- coding: utf-8 -*-
from selenium import webdriver

driver = webdriver.Chrome()
driver.implicitly_wait(30)
driver.get('https://login.taobao.com/member/login.jhtml')
driver.find_element_by_id("TPL_username_1").send_keys("myname")
time.sleep(1)
driver.find_element_by_id("TPL_password_1").send_keys("pwd")
time.sleep(1)
driver.find_element_by_id("J_SubmitStatic").click()
time.sleep(1)
error_text = driver.find_element_by_class_name('error').text
print error_text

我是新手,获取不到error,要怎么解决?

天蓬老师天蓬老师2858 days ago823

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 15:46:30

    Look at the documentation to find the method. There are two ways:
    The first one is to click directly on the picture:
    refreshlink = driver.findelementbyid('JStandardCodem')
    refresh_link.click()

    The second method is to get the image url, and then get
    link = refreshlink.getattribute('src')
    driver.get(link)

    Maybe I didn’t describe it clearly before. In this question, I just want to know how to get the verification code image.

    As for the identification problem, I really need it, so I’ll try it again.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 15:46:30

    Climb down and enter the verification code manually...or use an image processing library to automatically recognize the verification code.

    reply
    0
  • Cancelreply