Python obtains the implementation code of the title account number of the Douyin attention list

  • 2021-11-10 10:07:12
  • OfStack

Recently, the Tik Tok attention has reached the upper limit of 5,000, so many beautiful little sisters can't pay attention, so it is ok to get the account that has been blocked through python to cancel the attention

Implementation code


import requests
import json
import time

#  Tik Tok Creator Platform cookie
header = {'Cookie': ' Yours COOKIE'}
shijian = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
sbdy = str(0)
sl = 0
file = open("D:/test.txt", "a+",encoding='utf-8')
file.write(shijian)
yczh = 0

print(str(shijian)+"\n Start testing, please wait patiently ...")
while (sl < 5000):
    url = 'https://creator.douyin.com/aweme/v1/creator/relation/following/list/?aid=2906&app_name=aweme_creator_platform&device_platform=web&referer=https:%2F%2Fcreator.douyin.com%2Fcreator-micro%2Fhome&user_agent=Mozilla%2F5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F90.0.4430.212+Safari%2F537.36&cookie_enabled=true&screen_width=1536&screen_height=864&browser_language=zh-CN&browser_platform=Win32&browser_name=Mozilla&browser_version=5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F90.0.4430.212+Safari%2F537.36&browser_online=true&timezone_name=Asia%2FShanghai&_signature=_02B4Z6wo00901TSjMlwAAIDChFLelrWwFwk0pzbAAC2OgYeyEeDw.eiDhwpfH.4NSilIGJd.pSZ5de4SL4e-U2DQy-VLvH0NkfwTIp14WBZCgv63l6pLIkqBZMs9VRrdqIj3xOjfyY.2y6v8de&cursor='+sbdy+'&count=20'
    r = requests.get(url,headers=header)
    json_str = json.loads(r.text)

    if (int(json_str['status_code']) == int('0')):
        if ("user_info_list" in json_str):
            av = json_str['user_info_list']
            for d in av:
                url = str(d['avatar'])
                if (url == "c16000003f97583dac4" or url == "b76600039bd12b4c09da"):
                    print(" User name: "+d['nickname']+"  Abnormal ")
                    text = str('\n'+d['nickname'])
                    file.write(text)
                    sl+=1
                    yczh+=1
                else:
                    # print(" User name: "+d['nickname']+"  Normal ")
                    sl+=1
            sbdy = str(json_str['cursor'])
        else:
            print(" The test is completed, and the account number has been tested "+str(sl)+" Total abnormal accounts "+str(yczh)+" A ")
            print(" The abnormal account number is stored in the : "+file.name)
            file.close()
            exit()
    else:
        if ("status_message" in json_str):
            print(json_str['status_message']+" , checked account number "+str(sl)+" A ")
            print(" Wait 3 Minutes to continue execution ")
            time.sleep(180)
            print(" Continue execution ")
        else:
            print(json_str)
            print(sbdy)
            yn = input(" Do you want to retry and continue? [y/n]")
            if (yn == "n"):
                file.close()
                exit()

It is necessary to manually go to the Tik Tok creator platform to obtain cookie. Note that only users who seal the avatar will also obtain it, because the principle is to judge the avatar address
I am a novice, learn Python to write, can use: loveliness:


Related articles: