Downloading A Picture of an individual Instagram post with with Instaloader and Python

Question:

Using Python and the Instaloader package I am able to to download A profile Picture via this code

import instaloader
        dp = instaloader.Instaloader()
        dp.download_profile(profile_name, profile_pic_only = True)

All I have to do is provide the profile name.

What I also want to archive is, I want to download the picture of an individual post, such as: https://www.instagram.com/p/CgbAU5GD6MU/

Can this be done with Python instaloader?

Thanks!

Asked By: 69JonDoe69

||

Answers:

Sure! Get the urls you want and easily use them

import instaloader

L = instaloader.Instaloader()
post_url = 'https://www.instagram.com/p/CgbAU5GD6MU/'
post = instaloader.Post.from_shortcode(L.context, post_url.split('p/')[1].strip('/ '))
photo_url = post.url   # this will be post's thumbnail (or first slide)
video_url = post.video_url  # if post.is_video is True then it will be url of video file
Answered By: realSamy

I’m sorry I can vote you but both the question and the answer where completelly useful for me. Tx!

Answered By: Luis W. Sevilla