Sending WeChat Messages with Python and Pushplus (Single and Group Push)
This tutorial explains how to use Python and the Pushplus service to send WeChat notifications, covering both single‑user pushes and one‑to‑many group pushes, with step‑by‑step instructions, required token setup, and complete code examples.
Python can be used to push messages to QQ Mail, Enterprise WeChat, WeChat, and other platforms; this article demonstrates how to send WeChat messages directly using Python and the third‑party tool pushplus .
Single Push
Steps:
Register an account on the Pushplus website using WeChat.
Copy the token provided and keep it for later use.
Code example:
<code>import requests
# Python source code collection group 279199867
def send_wechat(msg):
token = 'XXXXXXXXXXXX' # token copied from the website
title = 'title1'
content = msg
template = 'html'
url = f"https://www.pushplus.plus/send?token={token}&title={title}&content={content}&template={template}"
print(url)
r = requests.get(url=url)
print(r.text)
if __name__ == '__main__':
msg = 'Life is short I use python'
send_wechat(msg)
</code>Running the script on a mobile device shows the result.
Limitation: this method only pushes messages to yourself; others cannot receive them.
One‑to‑Many Push
Steps:
Create a group on the "One‑to‑Many Push" tab and record the group code.
Generate a QR code for the group and have recipients scan it with WeChat.
After scanning, the subscribed users appear in the group list; any message sent to the group will be received by all members.
Write code to send messages to the group.
Code example:
<code>import requests
def send_wechat(msg):
token = ' XXXXXXXXXXXXXXXXXX' # token copied from the website
title = 'test notice title'
content = msg
template = 'html'
topic = '1'
url = f"http://www.pushplus.plus/send?token={token}&title={title}&content={content}&template={template}&topic={topic}"
print(url)
r = requests.get(url=url)
print(r.text)
if __name__ == '__main__':
msg = 'this is a one to more lizi'
send_wechat(msg)
</code>The effect is displayed in the following screenshots.
Note: Pushplus offers free and paid (member) plans; free users can make up to 200 requests per day, while members can make up to 1,000. Purchasing a membership costs about 10 CNY per month and supports the service provider.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.