[Python detection Script] do you know that your friends block you? Do you know the end of shielding others? (Lahai, all Lahai)

preface

🚀 Author: "programmer pear"

🚀 ** Article introduction * *: This article mainly explains how to use Python to find out those people who block me in QQ space, and put them in

The whole process of pulling black.

🚀 ** Article source code acquisition * *: in order to thank everyone for paying attention to my little cute 💓 The project source code of each article is distributed free of charge

Enjoy drops 💓👇👇👇

Click here for the blue font. What source code do you need? Remember to say the title and name! I can also write private letters!

🚀 Welcome to praise 👍, Collection ⭐, Leaving a message. 💬

text

"Record and make every step of growth clearly visible"

Has QQ been with you for many years - all the emotions in primary school, junior middle school, high school and childhood, joy, anger and sadness

happy... BUT generally, I use very little after I go to College: a few days ago, my friend found the photos of a long time ago and sent them to me, saying that the space suddenly changed

It's interesting to say! So I began to turn the space.

During this process, I found that the QQ space of many friends blocked me. We don't know how to provoke others,

In a rage, I wrote a little reptile to see who blocked me!

                       

I. operating environment

Python 3.0, which is basically available for all Python versions, is installed and prepared in the environment 7. Pycharm2021

Third party library environment: requests, lxml, threadpool, selenium.

The method often used to install modules, that is, the small compilation of third-party modules, is: pip install + module name or mirror required for speed-up

Like the source, baidu or csdn search will come out a lot of image sources for installing modules, which will not be introduced one by one here!

2, Thinking steps

1) First, use selenium to simulate login to obtain cookie s and save them locally.

2) Find the interface to view your friends.

Enter my space, click F12 to check the interface, empty the Network and click the friends interface.

The preferred blind guess friends list contains a friend field. Directly select the search to find some data, and find the friend word one by one

Paragraph. Save the currently obtained url for future query.  

 

Then} crack the encryption parameters in data.

See only one g_tk encryption parameters are very excited, just an encryption!

Go to Sources and search G_ What exactly is the TK value encrypted? It is found that it is a function. After looking in, it is found that it is a simple small addition

Secret. You can write python code.

Python code is as follows:

def get_g_tk(): # Encryption algorithm P in QQ space_ skey = cookie['p_skey']    h = 5381    for i in p_ skey:        h += (h << 5) + ord(i)        g_tk = h & 2147483647    return g_tk

3) Get the friends list in the friends column of QQ space

After getting the encryption parameters, we just need to enter the space friends column page just mentioned and capture the QQ numbers of all our friends

Come on, use urlib parse. URLEncode (data) converts the parameter to our common url, followed by a long string of & & &, which is the same as the original chain

After splicing, you can bring cookies and send a request to get json data.

def get_friends_uin(g_tk): # Get your friend's QQ number information yurl = 'https://user.qzone.qq.com/proxy/domain/r.qzone.qq.com/cgi-bin/tfriend/friend_ship_manager.cgi?'    data = {            'uin': cookie['ptui_loginuin'],            'do': 1,            'g_tk': g_tk            }    url = yurl + urllib.parse.urlencode(data)    res=requests.get(url, headers = headers, cookies = cookie)    r = res.text.split('(')[1].split(')')[0]    friends_list=json.loads(r)['data']['items_list']    friends_uin=[]    for f in friends_list:        friends_uin.append(f['uin'])    return friends_uin

4) Find the cruel man who shielded me.

Those who have been denied access should be noted down

def get_blacklist(friends): # Query blocked friends QQ No. write it down in a small book!    access_denied=[] # Pull the black note and write it down!    yurl = 'https://user. qzone. qq. COM / 'for friend in friends: Print ("start check:" + str (friend)) url = yurl + str (friend) res = requests get(url,headers=headers,cookies=cookie)        tip = etree. HTML(res.text). XPath ('/ HTML / body / div / div / div [1] / P / text()') if len (tip) > 0: #if tip [0] [: 7] = = "the owner has set permissions": print(str(friend) + "black me!") access_denied.append(friend)    return access_denied

5) Finally, join the restricted list and blackmail them!

It is found that there is only one post request, which should be the only one.  

After looking at the required parameters, your own number, black number, your own space, plus a useless parameter and the encryption parameter just obtained.

Pull black code:

def pull_black(): # Pull black, must pull black! global cookie    cookie = search_ cookie()    with open('access_denied.txt', 'r') as f:        access_ denied = f.readlines()    for fake_ friend in access_ denied:        fake_ friend = fake_ friend. split('\n')[0]        yurl = " https://user.qzone.qq.com/proxy/domain/w.qzone.qq.com/cgi-bin/right/cgi_black_action_new? "        g_tk = get_g_tk()        url_data = {'g_tk': g_tk}        data = {            'uin': cookie['ptui_loginuin'],            'action': '1',            'act_uin': fake_friend,            'fupdate': '1',            'qzreferrer': ' https://user.qzone.qq.com/1223411083 '        }        url = yurl + urllib. parse. urlencode(url_data)        res=requests. Post (URL, headers = headers, data = data, cookies = cookies) print (STR (fake_friend) + "you've blacked it") print("it's black! Detoxify!!")

summary

All right! This article is written here. Go and see who your QQ friends have blocked you~

Follow Xiaobian for more wonderful content! Remember to click on the portal 👇

It's not easy to make. Remember to click three times!! If you need to share the packaged source code + materials for free!! Portal

Keywords: Python Programmer crawler

Added by yong on Tue, 18 Jan 2022 17:12:46 +0200