|
|
|
|
import time
|
|
|
|
|
from selenium import webdriver
|
|
|
|
|
from selenium.webdriver.common.by import By
|
|
|
|
|
from selenium.webdriver.common.keys import Keys
|
|
|
|
|
|
|
|
|
|
options = webdriver.EdgeOptions()
|
|
|
|
|
|
|
|
|
|
options.add_argument("--start-maximized") # 最大化窗口
|
|
|
|
|
options.add_argument("--disable-notifications") # 禁用通知
|
|
|
|
|
|
|
|
|
|
options.add_argument("user-data-dir=C:/Users/JJM/AppData/Local/Microsoft/Edge/User Data/Default") # 使用本地用户数据目录
|
|
|
|
|
|
|
|
|
|
options.add_experimental_option("detach", True)
|
|
|
|
|
|
|
|
|
|
driver = webdriver.Edge(options=options)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
driver.get("https://www.douyin.com/user/MS4wLjABAAAAL8jDZ46yxoNUO9cr312r6PcKPYNipzcHqIKFbfpQIxM")
|
|
|
|
|
|
|
|
|
|
driver.implicitly_wait(15) # 隐式等待,最长等20秒
|
|
|
|
|
time.sleep(6)
|
|
|
|
|
|
|
|
|
|
buttons = driver.find_element(By.XPATH,'//div[@class="hLIm2dFu"]/button[@class="semi-button semi-button-secondary RH8TCnaE z0c5Gipx I4tJiW0Q"]')
|
|
|
|
|
|
|
|
|
|
buttons.click()
|
|
|
|
|
driver.implicitly_wait(15) # 隐式等待,最长等20秒
|
|
|
|
|
time.sleep(5)
|
|
|
|
|
|
|
|
|
|
# j6SRMBFG
|
|
|
|
|
# divi = driver.find_element(By.XPATH,'//div[@class="IaCaREVo"]')
|
|
|
|
|
# divi = driver.find_element(By.XPATH,'//div[@class="j6SRMBFG"]')
|
|
|
|
|
# divi.click()
|
|
|
|
|
# 定位输入框,正常输入框是input,但是这个用的是div,然后div有一个contenteditable属性设置成true就变成了输入框了
|
|
|
|
|
# 所以定位带contenteditable 属性的div相当于定位了输入框input
|
|
|
|
|
divn = driver.find_element(By.XPATH,'//div[@class="notranslate public-DraftEditor-content"]')
|
|
|
|
|
|
|
|
|
|
time.sleep(3)
|
|
|
|
|
divn.send_keys('6666666666',Keys.ENTER)
|
|
|
|
|
time.sleep(5)
|
|
|
|
|
ent=driver.find_element(By.XPATH,'//div[@id="root"]')
|
|
|
|
|
ent.send_keys(Keys.ENTER)
|
|
|
|
|
time.sleep(3)
|
|
|
|
|
spans = driver.find_element(By.XPATH,'//span[@class="sCp7KhBv EWT1TDgs e2e-send-msg-btn"]')
|
|
|
|
|
spans.click()
|