无头参数设置:
from selenium.webdriver.edge.options import Options
options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
规避参数设置:
options.add_experimental_option('excludeSwitches',['enable-automation'])
定位标签:
from selenium.webdriver.common.by import By
全代码
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver.edge.options import Options
options = Options()
# 无头参数设置
options.add_argument('--headless')
options.add_argument('--disable-gpu')
# 规避参数设置
options.add_experimental_option('excludeSwitches',['enable-automation'])
url = 'https://qzone.qq.com/'
driver = webdriver.Edge(options=options)
driver.get(url)
# 定位账号密码登录所在的标签
driver.switch_to.frame('login_frame')
login_link = driver.find_element(By.ID,value='switcher_plogin')
login_link.click()
account = driver.find_element(By.ID,value='u')
account.send_keys('1111111')
sleep(1)
pwd = driver.find_element(By.ID,value='p')
pwd.send_keys('*****')
sleep(2)
login_button = driver.find_element(By.ID,value='login_button')
login_button.click()
sleep(4)
driver.quit()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)