• 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()
  • 相关阅读:
    从零搭建hadoop集群之安装虚拟机
    数据库中的左连接和右连接的区别
    cookie 和session的区别是
    jquery获取单选按钮选中的值
    css设置背景图(背景图太大导致图片显示不全)
    vue购物车
    model修改器获取器的使用
    model时间戳自动添加
    定义路由
    模型使用:M模型 V视图 C控制
  • 原文地址:https://www.cnblogs.com/cong12586/p/13462419.html
Copyright © 2020-2023  润新知