python爬虫之登陆QQ空间
点击密码登陆后输入账号密码点击登录
#需求:登陆QQ空间
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
#导入动作链对应的类
from selenium.webdriver import ActionChains
from selenium.webdriver.edge.options import Options
edge_options = Options()
edge_options.add_argument("--guest") # 启用guest模式。
# edge_options.add_experimental_option("detach",True)
# 创建一个Edge WebDriver实例
bro = webdriver.Edge(options=edge_options)
bro.get('https://qzone.qq.com/')
bro.switch_to.frame('login_frame')
a_tag = bro.find_element(By.ID,'switcher_plogin')
a_tag.click()
username_tag = bro.find_element(By.ID,'u')
password_tag = bro.find_element(By.ID,'p')
username_tag.send_keys('账号')
sleep(1)
password_tag.send_keys('密码')
sleep(1)
btn = bro.find_element(By.ID,'login_button')
btn.click()
sleep(3)
bro.quit()