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.
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/5/8 11:28 # @Author : baoshan # @Site : # @File : daily_sentence.py # @Software: PyCharm Community Edition from threading import Timer from wxpy import * import requests bot = Bot(console_qr=2, cache_path="/home/admin/scripts/py/fangyuan/botoo.pkl") def get_news1(): # Get Kingsoft 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'你好')[0] my_friend.send(get_news1()[0]) my_friend.send(get_news1()[1][5:]) my_friend.send(u"Chicken soup for the soul from my husband!") print(get_news1()[0]) print(get_news1()[1]) t = Timer(86400, send_news) #Every 86400 seconds (1 day), send 1 time, do not use linux timed 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 it t.start() except: my_friend = bot.friends().search(u'宝山')[0] my_friend.send(u"Failed to send message today") if __name__ == '__main__': send_news()
The fly in the ointment is that the program execution needs to scan the code to log in to the web version of WeChat, so the computer client-side WeChat cannot be used.
It would be great if you could log in at the same time!
I also hope that the heroes will be generous to enlighten me.
Reprinted from: http://dataunion.org/32730.html