Preface:

Python bulk delete about QQ space tutorial bar. Without further ado, let’s begin happily

The development tools

Python version: 3.6.4

Related modules:

DecryptLogin module;

The argparse module;

And some of the modules that come with Python.

Environment set up

Install Python and add it to the environment variable, and the PIP will install the appropriate module.

Introduction of the principle

As before, let’s use our open source DecryptLogin package to implement a wave of simulated login operations in Qzone:

from DecryptLogin import login

@staticmethod
def login():
    lg = login.Login()
    infos_return, session = lg.QQZone()
    return session

Then, we go to Qzone to catch a wave of packages, that is, after entering Qzone, press F12 to open the developer tools, and then click the talk button, you can find the following link:

That is:

https://user.qzone.qq.com/proxy/domain/taotao.qq.com/cgi-bin/emotion_cgi_msglist_v6?

It can go back to the talk data on the top page of the talk page. A brief analysis of the parameters that the link needs to carry:

Uin: user's QQ number ftype: can always be '0' sort: can always be '0' pos: can always be '0' num: can always be '20' replynum: can always be '100' callback: It can always be '_PreloadCallback' code_version: it can always be '1' format: it can always be 'jsonp' need_private_comment: it can always be '1' 2. The parameter G_TK QZOneToken is not easy to know

Where g_tk is what we said in the previous article:

Simulation log series 1 | login login QQ space simulation series 2 | login QQ space simulation

Find the corresponding JS code:

And then we can change it to py:

Def __calcGtk(self, string): e = 5381 for c in string: e += (e << 5) + ord(c) return 2147483647&e

For the parameter QZOneToken, we can also find the corresponding JS code:

Turns out it could be a fixed number. Write a simple program to test it:

"" Get the home page of talk data def __getAllTwitters(self): url = 'https://user.qzone.qq.com/proxy/domain/taotao.qq.com/cgi-bin/emotion_cgi_msglist_v6?' params = { 'uin': self.uin, 'ftype': '0', 'sort': '0', 'pos': '0', 'num': '20', 'replynum': '100', 'g_tk': self.g_tk, 'callback': '_preloadCallback', 'code_version': '1', 'format': 'jsonp', 'need_private_comment': '1', 'qzonetoken': '12a2df7fc3ce126e67c62b0577cdea5133e79e77f46ae920b2a8b822ac867e54416698be9ee883f09e' } response = self.session.get(url, params=params) response_json = response.content.decode('utf-8').replace('_preloadCallback(', '')[:-2] response_json = json.loads(response_json) msglist = response_json['msglist'] if msglist is None: msglist = [] all_twitters = {} for item in msglist: tid = item['tid'] created_time = item['created_time'] content = item['content'] all_twitters[tid] = [created_time, content] return all_twitters

You can find the data returned as follows:

And the data on our home page is the same:

It seems that our previous analysis is absolutely correct. Now, we only need to catch the package to see the deletion about the need to request which interface OK (oneself manually delete a talk can catch this interface, very simple) :

The following parameters need to be carried:

T1_source: fixed value '1' code_version: fixed value '1' format: fixed value 'fs' qzreferrer: Format for 'https://user.qzone.qq.com/ #} {user QQ/infocenter'

So now we can happily start coding:

External call def run(self): url = 'https://user.qzone.qq.com/proxy/domain/taotao.qzone.qq.com/cgi-bin/emotion_cgi_delete_v6?' del_count = 0 total_count = 0 while True: all_twitters = self.__getAllTwitters() if not all_twitters: Break for key, value in all_twitters. Items (): total_count += 1 print('[INFO]: '% (total_count, del_count)) if self.is_manual: print(' %', '%', '%', '%', '%') ' % (str(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(value[0]))), Value [1])) if user_input.lower() == 'n' or user_input.lower() = 'no': continue data = { 'hostuin': self.uin, 'tid': key, 't1_source': '1', 'code_version': '1', 'format': 'fs', 'qzreferrer': f'https://user.qzone.qq.com/{self.uin}/infocenter' } params = { 'qzonetoken': self.qzonetoken, 'g_tk': self.g_tk } try: response = self.session.post(url, data=data, params=params) del_count += 1 time.sleep(random.randrange(1, 3)+random.random()) except: pass time.sleep(random.randrange(3, 6)+random.random()) print('[INFO]: After the program has finished running, a total of %s of your account has been detected, among which %s has been successfully deleted. ' % (total_count, del_count))

This is the end of the article, thank you for watching, pay attention to me every day to share Python simulation login series, the next article to share terminal to see netease cloud daily song recommendation.

To thank you readers, I’d like to share with you some of my recent collection of dry programming goodies and give something back to every reader in the hope of helping you out.

Dry goods mainly include:

① More than 2000 Python e-books (mainstream and classic books are available)

(2) The Python Standard Library (Chinese version)

③ project source code (40 or 50 interesting and classic hands-on project and source code)

④Python basic introduction, crawler, web development, big data analysis video (suitable for small white learning)

⑤ Python Learning Roadmap (Goodbye to Slow Learning)

All done~ complete source code + dry goods see personal profile or private message to obtain the relevant files.