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.

44 lines
1.4 KiB

6 months ago
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from time import sleep
6 months ago
from selenium.webdriver.edge.service import Service
from selenium.webdriver.edge.options import Options
6 months ago
6 months ago
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)
6 months ago
my_url = "https://www.douyin.com/"
driver_edge.get(my_url)
6 months ago
sleep(5)
6 months ago
6 months ago
#x=driver_edge.find_element(By.XPATH,'//*[@id="login-pannel"]/div[2]')
#x.click()
#sleep(1)
6 months ago
# 模拟点击
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)
6 months ago
6 months ago
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()
6 months ago
# 获取cookie
cookies = driver_edge.get_cookies()
for cookie in cookies:
print(cookie)
6 months ago
6 months ago
# 关闭浏览器
driver_edge.quit()