1

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!

69JonDoe69
  • 41
  • 1
  • 6

1 Answers1

0

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
realSamy
  • 189
  • 6
  • Hi realSamy, Thanks a lot for this quick and helpful response. Since I need need to build a wesbite similiar to this "https://en.savefrom.net/135/download-from-instagram", performance is important. I only need the post pic, not the complete post with comments, likes and hashtags. Is there an option, such as "post_pic_only=True"? – 69JonDoe69 Aug 19 '22 at 07:26
  • Edited, now it works as you want – realSamy Aug 19 '22 at 07:51
  • Wow, thanks for the aweseome help! However, this is only working, if I add the following line below the line where we instantiating the loader: "L.login(username,password")" Without the line, I get this Error: raise LoginRequiredException("Redirected to login page. Use --login.") instaloader.exceptions.LoginRequiredException: Redirected to login page. Use --login. "" The strange thing is, downloading the profile or just the profile_pic as described above works without this line. – 69JonDoe69 Aug 19 '22 at 08:59
  • seems instagram has some limits on using it without login, you may use an account to handle your project's needs – realSamy Aug 19 '22 at 09:26