How to get the URLs of the most recent posts of a Instagram user? (with Python)

1185 views python
6

I want to get the URLs of the most recent posts of an Instagram user (not me, and I don't have an IG account so I can't use the API). The URLs should be in the style of https://www.instagram.com/p/BpnlsmWgqon/

I've tried making a request with response = requests.get(profile_url) and then parsing the HTML with soup = BeautifulSoup(html, 'html.parser').

After these and some other functions I get a big JSON file with data of the most recent pics (but not their URLs).

How can I get the URLs and extract just that?

answered question

1 Answer

12

Could you not create an account? Doing it with the API is simple, as per below (This is not my own code. Source)

user_posts = insta.getUserFeed(usernameID, max_ID)
info = insta.LastJson
img_url = info['items'][0]['image_versions2']['candidates'][0]['url'].split("?")[0]

posted this

Have an answer?

JD

Please login first before posting an answer.