You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
from selenium import webdriver
|
|
|
|
from selenium.webdriver.common.by import By
|
|
|
|
|
|
|
|
from selenium.webdriver.common.keys import Keys
|
|
|
|
from time import sleep
|
|
|
|
from selenium.webdriver.edge.service import Service
|
|
|
|
from selenium.webdriver.edge.options import Options
|
|
|
|
|
|
|
|
|
|
|
|
options = webdriver.EdgeOptions()
|
|
|
|
options.add_argument("--start-maximized") # 最大化窗口
|
|
|
|
options.add_argument("--disable-notifications") # 禁用通知
|
|
|
|
options.headless = True
|
|
|
|
options.add_argument("user-data-dir=C:/Users/JJM/AppData/Local/Microsoft/Edge/User Data/Default") # 使用本地用户数据目录
|
|
|
|
|
|
|
|
|
|
|
|
driver_edge = webdriver.Edge(options=options)
|
|
|
|
|
|
|
|
my_url = "https://www.douyin.com/"
|
|
|
|
|
|
|
|
driver_edge.get(my_url)
|
|
|
|
sleep(5)
|
|
|
|
|
|
|
|
#x=driver_edge.find_element(By.XPATH,'//*[@id="login-pannel"]/div[2]')
|
|
|
|
#x.click()
|
|
|
|
#sleep(1)
|
|
|
|
# 模拟点击
|
|
|
|
|
|
|
|
search_box = driver_edge.find_element(By.XPATH,'//*[@id="douyin-header"]/div[1]/header/div/div/div[1]/div/div[2]/div/div/input').send_keys('zy2752629612',Keys.ENTER)
|
|
|
|
|
|
|
|
|
|
|
|
sleep(10)
|
|
|
|
s=driver_edge.find_element(By.XPATH,'//*[@id="search-content-area"]/div/div[1]/div[2]/div[1]/ul/li[1]/div/div/div/div/div/a/div/img')
|
|
|
|
x.click()
|
|
|
|
sleep(5)
|
|
|
|
h=driver_edge.find_element(By.XPATH,'//*[@id="douyin-right-container"]/div[2]/div/div/div[2]/div[3]/div[3]/div[1]/button[2]')
|
|
|
|
x.click()
|
|
|
|
# 获取cookie
|
|
|
|
cookies = driver_edge.get_cookies()
|
|
|
|
for cookie in cookies:
|
|
|
|
print(cookie)
|
|
|
|
|
|
|
|
# 关闭浏览器
|
|
|
|
driver_edge.quit()
|