我正在创建一个虚拟助手,我希望能够通过向 WhatsApp 聊天发送消息来使用它,助手可以在其中阅读消息、执行其功能并发送响应,为此我想使用 selenium图书馆。 我的问题来自于我不明白如何选择合适的聊天来发送。 查看 WhatsApp 网络代码,我看到聊天分为 span 标签,这些标签具有标识每个聊天的文本。 我如何选择我想要的聊天并发送消息本身? `
from selenium import webdriver
import time
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
driver_path = '/home/santiago/asistente/chromedriver/'
service = Service(executable_path=driver_path)
driver = webdriver.Chrome(service=service)
def chose_chat() :
elements = driver.find_element(By.TAG_NAME, 'span')
?????
elements.click()
print ("Im here")
return False
def botwhatsapp():
driver.get('https://web.whatsapp.com/')`
input('Press enter when you are ready: ')
chose_chat()
botwhatsapp()`
我曾尝试使用其他库或以前的版本,但我找不到任何当前版本并且 whatsapp web 更改了它的结构或标签