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()
  • 相关阅读:
    vss
    JavaScript中的5种事件使用方式解说
    loadrunner
    NET体系结构图
    eclipse Java Build Path
    httpModules 与 httpHandlers
    redhat linux5 安装配置 JDK1.6+Tomcat6+Apache2.2.x+jk_mod1.2
    如何在线使用MSDN
    petshop
    ADO.NET Entity Framework 使用数据定义语言(实体框架)
  • 原文地址:https://www.cnblogs.com/cong12586/p/13462419.html
Copyright © 2011-2022 走看看