【发布时间】:2022-11-13 21:35:38
【问题描述】:
我正在尝试使用 selenium 在不和谐频道上选择最后一条消息 我找不到xpath。 xpath 每次都在更改最后一条消息。我只想复制频道上的最后一条消息。最后一条消息 ID 更改。请帮我。此代码正在记录并轮换到 chanel。
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
import os, shutil
driver = webdriver.Chrome()
driver.get("https://discord.com/login")
time.sleep(6)
#--------------- Edit Here -------------------------------------------------------------
# Enter your account details here
username = ''
password = ''
# Copy the URL of channel where you wanna send messages and paste below
channelURL = "https://discord.com/channels/775349757060186142/77535656021144289331"
#-------------- Edit End ----------------------------------------------------------------
# Initialize and input email
username_input = driver.find_element_by_name('email')
username_input.send_keys(username)
# Initialize and input password
password_input = driver.find_element_by_name('password')
password_input.send_keys(password)
# Initialize and login
login_button =
login_button.click()
print(">>Login Complete!")
time.sleep(10)
driver.get(channelURL)
print(">Opening The Server Link...")
time.sleep(5)
# Msg Sending
msgoutput = # I can't find last message's xpath
print("last message is")
print(msgoutput)
【问题讨论】: