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()
  • 相关阅读:
    音乐欣赏之歌词-《我们的歌》
    Office2007能够直接发日记了
    唯美的十大经典句子
    音乐电影-特务J
    FIFA2008封面人物
    夜深了,你的手机关机吗?
    第一次的,也是最后的情书
    ACCESS定时远程备份
    SVN Server
    [Joomla] SQL加入Joomla用户
  • 原文地址:https://www.cnblogs.com/cong12586/p/13462419.html
Copyright © 2011-2022 走看看