所以我目前正在尝试复制消息以自动执行登录序列。登录需要将 otp 代码发送到手机。我设置了一个 textnow 帐户以通过网页访问 otp,但在尝试查找最新消息时出现问题。即使每条消息的 html 看起来完全相同,我如何指定要复制最新元素。它们唯一的区别是给出的 otp 和时间。
senderofotp = driver.find_element_by_xpath('//*[@id="chat-preview-list"] /ul/li[1]/div[2]/div[1]/span/div')
senderofotp.click()
上面的代码是我选择消息发件人的方法。
message = driver.find_element_by_xpath('//*[@id="messageView"]/ul/li[30]/div/div[1]/div/div[1]/div/span/span')
即使当我尝试抓取消息时,它也会为我提供整个消息 View 的 xpath
最佳答案
您可以使用find_elements_by_xpath
一次查找元素列表
关于python - 在消息列表中查找最新消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59573124/