【发布时间】:2017-06-22 03:56:37
【问题描述】:
我发现 this python script on github 通过 Selenium 发送自动 WhatsApp Web 消息。
#https://www.github.com/iamnosa
#Let's import the Selenium package
from selenium import webdriver
#Let's use Firefox as our browser
web = webdriver.Firefox()
web.get('http://web.whatsapp.com')
input()
#Replace Mr Kelvin with the name of your friend to spam
elem = web.find_element_by_xpath('//span[contains(text(),"Mr Kelvin")]')
elem.click()
elem1 = web.find_elements_by_class_name('input')
while True:
elem1[1].send_keys('hahahahahahaha')
web.find_element_by_class_name('send-container').click()
尽管它是用来发送垃圾邮件的,但我试图将它改编成一个好的目的,但目前的脚本似乎不起作用。它不是通过 WhatsApp Web 发送消息,而是简单地加载一个 QR 身份验证屏幕,然后在我使用手机进行身份验证后它什么也不做。
关于为什么会发生这种情况的任何线索?我在 Firefox 上运行最新版本的 Selenium WebDriver,并且 geckodriver 已经被提取到 /usr/bin/。
【问题讨论】: