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.
46 lines
1.6 KiB
46 lines
1.6 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
|
||
|
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") # 使用本地用户数据目录
|
||
|
options= webdriver.EdgeOptions()
|
||
|
options.add_experimental_option("detach", True)
|
||
|
|
||
|
driver_edge = webdriver.Edge(options=options)
|
||
|
|
||
|
my_url = "https://www.douyin.com/"
|
||
|
|
||
|
driver_edge.get(my_url)
|
||
|
sleep(11)
|
||
|
|
||
|
x=driver_edge.find_element(By.XPATH,'//*[@id="login-pannel"]/div[2]')
|
||
|
x.click()
|
||
|
sleep(10)
|
||
|
# 模拟点击
|
||
|
|
||
|
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(15)
|
||
|
|
||
|
s=driver_edge.find_element(By.XPATH,'//*[@id="search-content-area"]/div/div[1]/div[2]/div[1]/ul/li/div/div/div/div/div/a')
|
||
|
s.click()
|
||
|
sleep(5)#/html/body/div[2]/div/div[2]/div[2]/div/div[1]/div[2]/div[1]/ul/li/div/div/div/div/div/a//*[@id="search-content-area"]/div/div[1]/div[2]/div[1]/ul/li/div/div/div/div/div/a
|
||
|
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]')
|
||
|
h.click()
|
||
|
# 获取cookie
|
||
|
cookies = driver_edge.get_cookies()
|
||
|
for cookie in cookies:
|
||
|
print(cookie)
|
||
|
|
||
|
# 关闭浏览器
|
||
|
driver_edge.quit()
|