Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python to view Wechat withdrawal messages

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to use Python to view Wechat withdrawal messages", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to use Python to view Wechat withdrawal messages"!

I. functional design

Let's show you the functions that have been realized.

Second, function realization

1. The implementation principle of Wechat withdrawing message

Let's first take a look at how Wechat withdraws messages:

In fact, the principle of Wechat withdrawal message is that when the operator clicks to withdraw, the client will automatically send a system message: "xxx withdrew a message". Then the append of the other side receives the message and parses it, replacing the original message and changing the display style.

Let me show you the difference between the contents of a normal message and a withdrawn message:

Normal news: Content=', you are so slutty. 'everybody pay attention to MsgId='8784390488772995470'.

Recall message: Content is a string of content in xml format

Let's format it below.

Xxx 1090336364 8784390488772995470

By analyzing the Content field recalled above, we find that the id of 8784390488772995470 is the same as the id we sent before, and this tag verifies our conjecture that the original message is indeed replaced with a new message.

two。 Find the recalled message

According to the contents of crawling normal messages and withdrawing messages, we find the rule: the recall message will contain the msgid of the previously recalled message, then we just need to find the previous message, while the wxpy module defaults to that we have cached the last 200 messages, so we just need to traverse these historical messages and compare msgid to find the recalled message!

If your Wechat messages are too frequent and the number of messages exceeds 200 within 2 minutes, you can set the max_history to be larger.

3. Forward recalled messages

The principle is understood, and the withdrawn message is also found. The last step is to forward the message. If you have played wxpy before, you will surely do it. You can forward the message with just one line of code:

Msg.forward (bot.file_helper)

4. Code

When the principle and process are finished, the code will be posted for everyone to have a look at. The comments are still more detailed.

III. Functional verification

At this point, I believe you have a deeper understanding of "how to use Python to view Wechat withdrawal messages". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report