简体   繁体   中英

Send WhatsApp message every 24 hours

I want to send a WhatsApp message every 24 hours automatically using python, with the pywhatkit library. Here is the code I got so far:

import pywhatkit

pywhatkit.sendwhatmsg("+91xxxxxxxxxx", "Hello, world", 16, 00)

Send every 24 hours adaptation:

import pywhatkit
import time
   
while True:
    time.sleep(86400) #86400 seconds in a day
    pywhatkit.sendwhatmsg("+91xxxxxxxxxx","Hello, world", 16, 00)

I would have to keep my PC on 24/7 for this to work. Is there any better way of doing it?

See you can use pywhatkit, and can add a loop using python library like this you can get hours

from datetime import datetime

# datetime object containing current date and time
now = datetime.now()
 
import time

time.strftime('%X') // '13:12:47'

time.strftime('%x') // '01/20/22'

time.strftime('%d') // '20' day

time.strftime('%m') // '01' month

time.strftime('%y') // '20' year

time.strftime('%H') // '01' hour

time.strftime('%M') // '01' minute

time.strftime('%m') // '01' second

but I recommend instead of pywhatkit use this, this is very fast and never misses,

https://stackoverflow.com/a/71168835/6236959

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM