Download Instagram Photo Through Python

Python Zac 2 years ago (2018-02-13) 2960 views 0 comments

Description:

As you know, there are many websites can let you download Instagram photos online. What if we use Python to achieve the same effect? It is not difficult.

 

 

Showing results

For example, we want to download Ariana Grande’s photos. Now we can to go her personal Instagram home page and click one of those photos.

 

Scraping Ariana Grande's Instagram picture

IMAGE.01

 

Copy the start_URL and run Python program.

Python code

IMAGE.02

 

It will show “Input your link”then you paste the start_URL which you copied just now. Once you have pasted the start_URL that you can press “Enter”

download Instagram photos through Python

IMAGE.03

 

The photo name is depends on the rule which we set up.

photo download complete

IMAGE.04

 

Preparatory work

  • Python IDE
  • Python version: 3.x
  • Python modules: requests, bs4(BeautifulSoup)

 

Step

1.Use ‘input’ function to receive start_URL.

1.Use Python ‘requests’ module to requests the start_URL.

2.BeautifulSoup to find the photo_URL which is inside tag<meta>.

3.Save to local storage.

 

Target Analysis

Remember the start_URL that we need to copy? If you forget, scroll to top find IMGAGE.01.

Access the start_URL through browser and right-click the photo.

IMAGE.05

We need to requests.get the URL and save ‘start_url’

 

 

Press F12 and find the photo_URL

scraping photo URL

IMAGE.06

 

As you know, the photo URL is inside tag<meta>, thie URL is after content

 

So we can use BeautifulSoup to find this tag

 

Because we have already find the photo URL which is after ‘content’, we just need write the code to save it.

 

 

Package the code

 

Say something…

This article might have some grammar errors. If you have any questions about this article(code, grammar) , please comment me. I will fix the errors. Thank you. I hope this article is helpful to you. If you like it, you can click ‘like’ to support me.

 

Like (12)
Comment
Cancel comment

emoji Image Bold Strilethrough Center Italic

Your email and address

  • Name (Required)
  • Email (Required)
  • Website(Optional)