Like and follow the implementation of Douyin protocol (python Douyin crawler)

        I have nothing to do. The previous article said that the basic functions of the Douyin data crawler have been implemented ( link to the previous article ). Then I studied the implementation method of likes and attention through the protocol. After continuous experiments, I finally realized the shaking. Tones automatically like and follow.

        Of course, to like and follow through agreement, you must first ensure that the account can be used normally. If the account cannot be like and followed on the real phone, then the agreement will not help. (Note: on this point, we will study later Is there a way to achieve it? The steps are as follows:

first step:

        Get the sec_user_id of the followed and liked account, sec_user_id can be obtained through uid.

The second step:

        Get the cookies of the account you want to operate. Cookies are used by Douyin to save the login information.

third step:

       Just ask Douyin to like and follow the interface.


The following code directly (take attention as an example):

params = {
            "sec_user_id": sec_user_id,
            "device_id": device_id,
            "type": 1,
            "channel_id": 0,
            "aid": "1128"
        }
        cookies = {
            "sid_guard": xxx
        }
api = gen_API(url, params)
ss= get_get_xg(api)
async with aiohttp.ClientSession() as session:
      async with session.get(ss['url'], cookies=cookies,headers=ss['headers']) as resp:
            try:
                ret = await resp.json()
                print(ret)
                data = ret['status_code']
                if not data:
                   raise Exception
            except:Exception
            return ret

The result of the request is as follows:

Among them, follow_status is 1 to indicate that the follower is successful, and it is done, so that the protocol can achieve batch follow and batch likes! ! ! !

Douyin crawler technology exchange, +v:YY_yhzf

Guess you like

Origin blog.csdn.net/nanxiaotiantian/article/details/104826486