Make Your Own Instagram29 Jul 2017 8 mins read (1500 words)
I deleted my Facebook on June 10th 2016, and upon this event—now that I sense the irony of it—I decided to tweet about it. I jumped from one network to the other, without really realizing that both profit off of selling my behavioral data regardless. Even Twitter makes money off of ads and behavioral data, but nothing comes close to Facebook. Even Google does not come close to what Facebook knows about certain aspects of its users, and how it has the capability to manipulate them psychologically.1 In her book Weapons of Math Destruction, Cathy O’Neil talks much about these systems.
Now that Facebook owns Instagram and WhatsApp, I have continued my move away from these services. Summer is the perfect time for me to do these moves, since I no longer rely on communications as much as I do during other times of the year. As of now, I have no Facebook-owned apps installed on my phone, because I feel no urge to sell my data in exchange for a manipulative service. Especially since there are plenty of other alternatives.
But I have to say, it is hard to be without Instagram because I no longer see what my friends are up to. Maybe this is a good thing. But it would still be nice to have the ability to have access to the feeds of my friends without being exploited by Facebook.
Getting the Username List
So first thing we have to do is get a list of usernames that we follow. There are plenty ways of doing this. Assuming that you don’t follow more 10000’s of accounts, the best way is to go to the web version of Instagram and click on the Following button to get a list of those who you follow.
Here we have a list of users that we follow.
Now we want to inspect each HTML element and find out the name of its HTML class. On Mac, we can press
Command+Option+I to bring up the HTML inspector.
By bringing the inspector, we can find out the HTML class name of each username element.
Now that we have the name of the HTML class which represents the usernames that we want, we need to output all the usernames into a list. In this particular example, the HTML class called
_4zhc5 is the one that represents the username text that we need to output into a list.
First, we have to paste a script that would allow us to save our username list to a text file. Here is a script, just paste it into your web console. It should work on most browsers.2
Like so, then press Enter.
Now we can paste the main script which will download a text file to our Downloads folder. Remember to substitute
_4zhc5 with whatever HTML class name that represents usernames.
Copy and paste this script into the console just like the previous one.
Once we do that, we should get a file with a list of usernames downloaded by our browser called
insta-following-list.txt which will be formatted like so:
This is quite nice since we can now use this list to scrape the Instagram accounts of these listed usernames.
Now that we have a list of usernames that we want to scrape, we can use a script called instagram-scraper. Open a new window terminal and download the script and type in the following (ignore the
Now create a folder in your home directory to where we will scrape our Instagram content:
instagram-scrapercommand to create folders for each username instead of dumping all images into
-dspecifies the destination to which we want to scrape our content. In this case it is
~/specifies that it is located in your home directory.
-fspecifies the file path to our
insta-following-list.txt. Find the path to this file, an paste it. On Mac, it should be
- The option
-lsignifies not to start script unless your login is successfully authenticated. This command is only necessary if you want to scrape private accounts. If you want to scrape only public accounts, use the command without
-land everything after it.
-uspecifies your Instagram username. Paste this without any quotes by replacing
-pspecifies your Instagram password. Paste this without any quotes by replacing
Note: There might be some problems with the script while it attempts to login into your Instagram account. Try resting your Instagram password and retry the command with the new password. This usually solves the problem.
Once you run the script successfully, you should get a folder structure similar to this one:
Now you have the Instagram content of all your usernames on your hard drive.
Creating a Browsable Web-Gallery (Optional)
Now that we scraped all these images, what is the point if they are just stored on our computer? We can create a Browsable web-gallery using a script called gallery_shell.
Open a new terminal window and type the following:
Cd to your home directory:
Download the script:
Make the script executable:
Now cd to the folder containing all the scraped usernames:
Now this script will go throughout all the username folders located in
my-instagram/ folder and create a browsable html page with thumbnails for each username folder:
Done! Now we need to serve the web content using python:
Now type localhost:8000 into your web browser and you should see a list of Instagram usernames:
Once you click on ant of these links, you’ll see a thumbnail gallery for each username, including private accounts if you chose to include your Instagram credentials.
This is not exactly a copy of Instagram and looks more like a hack, but it is a very great way to continue using Instagram without being subservient to the systems owned by Facebook. Plus, you will be able to backup Instagram Stories which disappear from Instagram after 24 hours.
For the next blog, We’ll be looking at how to setup an Instagram backing up process.
This is not to state that Facebook takes advantage of this capability. In fact, even if it does, it would be hard for anyone outside of Facebook to prove it due to the nature of these hidden algorithms. However there is an abundance of evidence that Facebook does alter the feeds of its users. ↩