whatsapp自动发送信息
whatsapp是一款即时通讯工具有非常多的使用者,作为即时通讯工具,回复是否即时在跨境电商中是非常重要的,下面为大家介绍一下whatsapp自动发送信息。
whatsapp自动发送信息
现在可以有很多的工具可以实现whatsapp自动发送消息,python是一门很好用的编程语言,使用python就可以实现whatsapp自动发送。
python如何让whatsapp自动发送消息
因为whatsapp本身没有开放api,所以我们要通过在聊天窗口模拟鼠标和键盘的操作输入我们要发送的信息。
whatsapp 开放了一条api可以用来给陌生人发信息的
“https://web.whatsapp.com/send?phone=”+电话号码(+8613421514574这样的格式)
这里放上需要导入的库
import pyautogui
import webbrowser as w
import time
import xlrd #excel只读库
import pandas as pd
import pyperclip
其中pyautogui是 用来控制键盘鼠标的
webbrowser是用来调用网页的
pyperclip是用来复制粘贴用的
xlrd和pandas是用来打开和读取excel文件的
这里直接上代码:
import pyautogui
import webbrowser as w
import time
import xlrd #excel只读库
import pandas as pd
import pyperclip
def read_excel(): #读取excel数据,对各项进行赋值
data=xlrd.open_workbook(‘D:\python workspace\customer.xlsx’) #打开excel文件
table=data.sheets()[0] #打开第一张表
nrows=table.nrows #获取表的行数
ncols=table.ncols #获取表的列数
for i in range(1,nrows): #循环逐行赋值
phone=str(table.cell_value(i,0))
Orderfollow(phone);
def paste(info):#复制粘贴
pyperclip.copy(info)
pyautogui.hotkey(‘ctrl’, ‘v’)
def ChangeLine(): #whatsapp 换行
pyautogui.keyDown(‘shift’)
pyautogui.press(‘enter’)
pyautogui.keyUp(‘shift’)
return
def Orderfollow(phone): #订单信息通过键盘自动输入
w.open(‘https://web.whatsapp.com/send?phone=’+phone)
time.sleep(9)
pyautogui.dragTo(400,1200)
pyautogui.dragTo(730, 860, button=‘left’)
pyautogui.click(x=730, y=860)
info(“no answer”);
def info(status):#根据状态选择要发送的信息
if status==“no answer”:
infoe=‘The watch arrived your address, the deliveryman call you but no answer, what time is ok for the delivery sir?’
运行后就可以直接调用了,但是要建立一个excel表格放在指定路径里面。