As long as one thing, a little bit repetitive. I will consider how to use the program to achieve it.
Here to share with programmer friends how to send "good night", stories, news, etc. to friends on WeChat every day...
It is best to run it on the server, so that it is more convenient to hang in the background.
Prepare
code show as below:
#Do not copy the source code and run it, you need to change a few places from __future__ import unicode_literals from threading import Timer from wxpy import * import requests # bot = Bot() bot = Bot(console_qr=2,cache_path=”botoo.pkl”) #The QR code here is printed in the form of pixels! , if you are running on win environment, replace with bot=Bot() def get_news1(): #Get Kingsoft PowerWord daily sentence, English and translation url = “http://open.iciba.com/dsapi/ ” r = requests.get(url) contents = r.json()[‘content’] translation= r.json()[‘translation’] return contents,translation def send_news(): try: my_friend = bot.friends().search(u'respect the years with bare hands')[0] #Your friend 's WeChat name, not a note, nor a WeChat account. my_friend.send(get_news1()[0]) my_friend.send(get_news1()[1][5:]) my_friend.send (u "Chicken Soup for the Soul from Dad!") t = Timer(86400, send_news) #Every 86400 seconds (1 day), send 1 time, do not use linux scheduled tasks because every time you log in, you need to scan the QR code to log in, a very troublesome thing, let him keep Hang on t.start() except : my_friend = bot.friends().search('Changnian')[0] #Your WeChat name , not WeChat account. my_friend.send(u"Failed to send message today") if __name__ == " __main__ ": send_news()
The final effect is this:
Reprint link: https://mp.weixin.qq.com/s/N4ECvA-SGOYXKajPIdzc1Q
For more content, please pay attention to the public number: 51reboot operation and maintenance development