溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

selenium學習:獲取驗證信息

發(fā)布時間:2020-06-03 02:44:58 來源:網(wǎng)絡 閱讀:365 作者:91ctt 欄目:軟件技術(shù)

獲得驗證信心的方式分別是:title URL text

from selenium import webdriver
from time import *
driver = webdriver.Chrome()
url = 'http://home.51cto.com/index?reback=http://9603083.blog.51cto.com/'
driver.get(url)

#打印當前頁面
title = driver.title
print(title)

#打印當前頁面URL
now_url = driver.current_url
print(now_url)

#執(zhí)行登陸
driver.find_element_by_xpath('//*[@id="loginform-username"]').clear()
driver.find_element_by_xpath('//*[@id="loginform-username"]').send_keys('91ctt')

driver.find_element_by_xpath('//*[@id="loginform-password"]').clear()
driver.find_element_by_xpath('//*[@id="loginform-password"]').send_keys('CTT1106648034')

driver.find_element_by_xpath('//*[@id="login-form"]/div[3]/input').click()

sleep(3)

#再次打印當前頁面
title = driver.title
print(title)
#打印當前頁面URL
now_url = driver.current_url
print(now_url)

#獲取用戶名
usr = driver.find_element_by_xpath('/html/head/meta[3]').text
print(usr)

sleep(3)
driver.quit()


向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI