千家信息网

selenium学习:获取验证信息

发表于:2024-10-25 作者:千家信息网编辑
千家信息网最后更新 2024年10月25日,获得验证信心的方式分别是:title URL textfrom selenium import webdriverfrom time import *driver = webdriver.Chrome
千家信息网最后更新 2024年10月25日selenium学习:获取验证信息

获得验证信心的方式分别是:title URL text

from selenium import webdriverfrom time import *driver = webdriver.Chrome()url = 'http://home.51cto.com/index?reback=http://9603083.blog.51cto.com/'driver.get(url)#打印当前页面title = driver.titleprint(title)#打印当前页面URLnow_url = driver.current_urlprint(now_url)#执行登陆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.titleprint(title)#打印当前页面URLnow_url = driver.current_urlprint(now_url)#获取用户名usr = driver.find_element_by_xpath('/html/head/meta[3]').textprint(usr)sleep(3)driver.quit()


0