[Asm] 纯文本查看 复制代码 from selenium import webdriver
import time
from selenium.webdriver.chrome.options import Options #无头导入设置
"""
# 无头浏览器
chrome_options = Options
# 增加无头
chrome_options.add_argument('--headless')
chrome_options.add_argement("--disable-gpu")
# 防止被网站识别
chrome_options.add_experimental_option('excludeSwitches',['enable_automation'])
browser = webdriver.Chrome(chrome_options=chrome_options)
"""
url = "https://www.douban.com/"
driver =webdriver.Chrome()
driver.get(url)
time.sleep(2)
rep1 = driver.find_element_by_xpath('//*[@id="anony-sns"]/div/div[3]/div/div[1]/ul/li[1]/div/a') #获取电影标签
rep2 = driver.execute_script("arguments[0].click();",rep1) #点击
#页面的回退
time.sleep(1)
driver.back()
#页面的前进
time.sleep(1)
driver.forward() |