In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail about Python | how to send messages automatically and regularly in Wechat. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Use the Python programming language to do a simple Demo demonstration of how to send messages automatically.
First, make a simple analysis of the problem:
The situations in which messages need to be sent on Wechat are roughly divided into two categories: group chat and personal conversation.
Messages are sent daily, Monday to Friday, at fixed time points, and at regular intervals at extreme points (for example, every 2 hours, every 30 minutes, every 20 seconds). )
The content sent is generally fixed, such as: "xxx, xxx, monitoring body temperature xx ℃", "Today's class is about to begin, please prepare in advance to attend the lecture", as well as fixed answers to specific questions.
Libraries that may need to be used (third-party libraries need to be imported in advance)
Schedule is a lightweight library of scheduled tasks in python that can complete scheduled tasks per minute, hour, day, day, and specific date.
Time, formatting date and time
Datetime, which is a collection of date and time modules
Itchat is an open source interface for personal ID of Wechat.
Here is a simple example.
Import schedule import timeimport itchatmyTpye = 0 # 0, individual user 1, group user myName=' Li Xiao'# Wechat user name mytime='13:27' # need to fix the time of sending messages endDay='2020-3-31'# deadline, that is, from now to March 31, 2020, send messages at 13:27 every day ss = 'isolated at home today, in good health Text now = time.strftime ("% d/%m/%Y") # get date itchat.auto_login () # login Wechat def job (): # Task if myTpye = = 0: # personal user2 = itchat.search_friends (name=myName) # personal itchat.send (ss) User2 [0] ['UserName']) # send messages elif myTpye = = 1: # Group myroom = itchat.search_chatrooms (name=myName) # Group itchat.send_msg (ss, myroom [0] [' UserName']) # Group users # list several sending cycles You can choose schedule.every (10) .minutes.do (job) # to send schedule.every (). Day.at (mytime) .do (job) # every ten minutes at a specified time every day. Monday.do (job) # send schedule.every (). Wednesday.at (mytime) .do (job) # send while now at a specified time every Wednesday < endDay:# judgment Is there a deadline for schedule.run_pending () # running all tasks time.sleep (3) # running interval now = time.strftime ("% d/%m/%Y") itchat.logout () # logging out of Wechat on "Python | how to send messages automatically and regularly in Wechat" this is the end of the article Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.