Using Instaloader to get usernames from hashtags on Instagram

by
published on
Use instaloader to get hashtag usernames

Instaloader allows you to harvest usernames from hashtags. Their documentation doesn't make this easy to figure out, so allow me to demonstrate.

Here is the command to do so:

instaloader --no-compress-json --no-pictures --no-videos --no-profile-pic --no-captions --count 50 --filename-pattern="{date_utc:%d-%m-%Y}|{profile}|" "#canada"

This command will be harvesting the latest 50 posts for the #canada hashtag. It doesn't download pictures, videos, or the post's captions into a seperate text file (default behavior). 

--filename-pattern="{date_utc:%d-%m-%Y}|{profile}|"

When we use {profile} in the filename-pattern, the Instaloader program has a little bit more work to do during it's scraping and this slows down the process a bit. When you ommit this function of looking up the username, Instaloader could scrape those 50 #canada posts in about 20 seconds. So keep this in mind when using this functionality with Instaloader.

Lets run the command in our terminal and take a look at the folder full of results... From running that command, we got 44 json meta files:

As you can see from the formatting of the files, the username is inbetween two | characters in the filename. Now all we have to do is run a simple cut command to extract all the names between these characters.

ls | cut -d '|' -f 2

  • ls - list all the files in the folder
  • cut - extract the text after the second | character 

Add them all to a textfile by adding > usernames to the end of the command.

That's all there is to it!

Comments

Powered by Hacks
© 2018, Sharegrams