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:\python\geckodriver.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()
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/61900.html
標籤:Python
上一篇:93復原IP地址。
