M
M
Maxim Buyanov2019-05-03 19:44:34
Python
Maxim Buyanov, 2019-05-03 19:44:34

How to get a link to a post with an instagram avatar?

There are services that provide a link to a post with an avatar of an Instagram account.
You can find such services by requesting "like/comment on Instagram profile picture".
I know how to get a profile picture on instagram, but I don't know how to get a link to a post with this photo so that I can comment on it. I would like to see the code mainly in Python, but you can use any other code, or get a link to an article / documentation where there is an answer to my question.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AWEme, 2019-05-04
@BenKenobi3

First you need to find out the user id, I think this will not cause difficulties.
Then we get json from the id of the avatar:

user_id = id жертвы
profile_pic = session.get(f'https://i.instagram.com/api/v1/users/{user_id}/info/').json()

We take the desired value:
And we get the shortcode of the post with the avatar:
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'

def id_to_code(media_id):
    shortcode = ''
    while media_id > 0:
        tail = media_id % 64
        media_id = (media_id - tail) // 64
        shortcode = alphabet[tail] + shortcode
    return shortcode

shortcode = id_to_code(pic_id)

Further, you know.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question