发送 Whatsapp 消息时,pywhatkit 中的循环在 python 中不起作用

发布于 2025-01-13 00:54:59 字数 257 浏览 3 评论 0原文

在下面的代码中,21 是小时,53 是分钟,10 是等待时间 在这段代码中,我想频繁地循环发送消息,但失败了。我也尝试过 for 循环,但它不起作用。任何人都知道如何使用 python 在 Whatsapp 中发送 100 条消息请帮助我

import pywhatkit
from flask import Flask
while 1:
  pywhatkit.sendwhatmsg("+9198xxxxxxxx", "Hi",21,53,10)

In below code 21 is hour and 53 is min and 10 is wait time
in this code I want to send message in loop frequently but I failed. I also tried for loop but it is not working. Any body know how to send 100 message in whatsapp using python please help me

import pywhatkit
from flask import Flask
while 1:
  pywhatkit.sendwhatmsg("+9198xxxxxxxx", "Hi",21,53,10)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

赠我空喜 2025-01-20 00:55:00

获取您当前的时间并添加一两分钟的延迟,然后应用在我的情况下有效的循环,我相信它也适合您 python3 pywhatkit while循环

from datetime import datetime
import pywhatkit
now = datetime.now()
current_time = now.strftime("%H:%M")
h,m= current_time.split(':')
h = int(h)
m = int(m)+2
while m<10:
    pw.sendwhatmsg("+********,"Hello, World!",h,m,10)
    m+=2

get your current time and add one or two minute delay then apply the loop it worked in my case, i am sure that it will work for you too python3 pywhatkit while loop

from datetime import datetime
import pywhatkit
now = datetime.now()
current_time = now.strftime("%H:%M")
h,m= current_time.split(':')
h = int(h)
m = int(m)+2
while m<10:
    pw.sendwhatmsg("+********,"Hello, World!",h,m,10)
    m+=2
烂人 2025-01-20 00:55:00

看,首先,pywhatkit 不会自动发送消息,它只是键入消息并打开该人的 DM,我们必须按 Enter 才能发送,因此要执行此操作,您也必须按 Enter a 100 次。其次,你不能这样做,因为使用 sendwhatmsg_instantly() ,消息会立即发送,并且仅使用 sendwhatmsg() 方法需要时间部分,并且每次登录时间都不同,你无法确定这一点,所以不要使用 Whatsapping给某人发消息 100 次,改为使用 smtplib 发送电子邮件--

import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login(youremailid, yourgmailpassword)      
server.sendmail(youremailid, to, content)
server.close()
#you can perform this in a For loop

look, first of all, pywhatkit does not send a message automatically, it just types the message and opens the DM of that person and we have to press enter to send, so to do this, you would have to press enter a 100 times too. Secondly, You cant do this because using sendwhatmsg_instantly(), the message goes on the spot and using only the sendwhatmsg() method requires a section for time and every time the login time is different and you cant determine that, so instead of whatsapping a message to someone 100 times, send an email instead using smtplib--

import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login(youremailid, yourgmailpassword)      
server.sendmail(youremailid, to, content)
server.close()
#you can perform this in a For loop
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文