How You can Scrape Instagram with Python

Edward Jones
3 min readDec 8, 2020

How you can use the instaloader package in Python to scrape Instagram data

Source: Mematic (created by me)

This Article is for You

If you want to learn:

  • Automatically download pictures (or videos) along with their captions and other data from Instagram
  • How to use the instaloader package in Python
  • How to process your downloaded data in a clean excel file

Install Instaloader

Instaloader is a tool to download pictures (or videos) along with their captions and other metadata from Instagram.

Install Instaloader with the pip command and import the package

! pip install instaloader
import instaloader

Write your scraping function that uses the instaloader features. Replace the strings “username” & “password” with your own or a new Instagram account to avoid errors.

def get_instagram_posts(username, startdate, enddate):
# Create an instaloader object with parameters
L = instaloader.Instaloader(download_pictures = False, download_videos = False, download_comments= False, compress_json = False)

# Log in with the instaloader object
L.login("username" , "password")
# Search the instagram profile…

--

--