zoukankan      html  css  js  c++  java
  • 06自动登录淘宝

    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait


    class tabao_info:
    def __init__(self):
    self.tabao_url = "https://login.taobao.com/member/login.jhtml"
    # 构造火狐浏览器。
    self.browser = webdriver.Firefox(executable_path="D:pythongeckodriver.exe")
    # 设置超时等待时间
    self.wait = WebDriverWait(self.browser,10)

    def login(self):
    # 打开网页
    self.browser.get(self.tabao_url)
    # 获取微博登录的界面
    if self.browser.find_element_by_xpath("/html/body/div/div[2]/div[3]/div/div[1]/div/div[2]/div/form/div[5]/a[1]"):
    self.browser.find_element_by_xpath("/html/body/div/div[2]/div[3]/div/div[1]/div/div[2]/div/form/div[5]/a[1]").click()
    # 获取微博登录的账号栏
    if self.browser.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div/div[2]/div/input'):
    print("hello")
    weibo_username = self.browser.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div/div[2]/div/input')
    weibo_username.send_keys("你的账号")
    # 获取微博登录的密码栏
    if self.browser.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div/div[3]/div/input'):
    print("world")
    weibo_password = self.browser.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div/div[3]/div/input')
    weibo_password.send_keys("cong829014.")
    # 获取登录按钮
    submit = self.browser.find_element_by_link_text('登录')
    # 点击登录
    submit.click()

    if __name__ == "__main__":
    tabao = tabao_info()
    tabao.login()
  • 相关阅读:
    STL next_permutation 全排列
    日期问题
    兰顿蚂蚁
    矩阵翻硬币
    数学问题-排列组合
    h5css3_03练习
    h5css3_03
    h5css3_02练习
    h5css3_02
    h5c3_01练习
  • 原文地址:https://www.cnblogs.com/cong12586/p/13462419.html
Copyright © 2011-2022 走看看