selenium——模拟qq空间登录

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from time import sleep
web_driver = webdriver.Chrome()
web_driver.get("https://qzone.qq.com/")
#切换作用域
web_driver.switch_to.frame("login_frame")
#标签定位
a_tag = web_driver.find_element(By.ID, "switcher_plogin")
a_tag.click()
sleep(5)
username_tag = web_driver.find_element(By.ID, "u")
password_tag = web_driver.find_element(By.ID, "p")
username_tag.send_keys("your_username")
sleep(2)
password_tag.send_keys("your_password")
sleep(2)
login_btn = web_driver.find_element(By.ID, "login_button")
sleep(2)
login_btn.click()
sleep(5)
print("?????????")
posted @ 2024-03-01 16:21  会秃头的小白  阅读(32)  评论(0编辑  收藏  举报