【问题标题】:How to automate web whatsapp to send messases with win32 api and pyautogui?如何自动化 web whatsapp 以使用 win32 api 和 pyautogui 发送消息?
【发布时间】:2021-02-15 02:01:55
【问题描述】:
谁能告诉我如何自动化网络 WhatsApp 向联系人列表中的每个人发送消息
或者建议我一个更好的选择,只要记住我不能购买付费 API。
【问题讨论】:
标签:
python
winapi
automation
whatsapp
pyautogui
【解决方案1】:
您可以使用 web.whatsapp.com 网址:
import webbrowser
import time
import pyautogui
phone = "12345678901"
text = "my message"
webbrowser.open(f"https://web.whatsapp.com/send?phone={phone}&text={text}&app_absent=0")
time.sleep(9) # wait for whatsapp web
pyautogui.click() # move your mouse to textbox before
pyautogui.press("enter")
【解决方案2】:
我尝试了 matan h 的答案,发现了几个错误。
我已经更新了下面代码中提到的 URL。
import webbrowser
import time
import pyautogui as gui
m_number = '91987654321' #country code and mobile number without '+' symbol
message = "You........"
url = 'https://web.whatsapp.com/send?phone='+m_number+'&text='+message+'&app_absent=0'
webbrowser.open(url)
time.sleep(10) #loading page time
gui.press('enter')