Forum Thread: Instagram Crawler - Flow (Part 2)

Hi i'm crawly.

We will be breaking down the basics of our script from part 1

How Does the Api Work?

instagramApi.py is a script that contains a class called 'InstagramAPI'
in our test.py script we imported this class using

from instgramApi import InstagramAPI

Note the capitilization of 'api'
instagramApi = the file we are importing from
InstagramAPI = the class inside the file

Next we created an object called 'bot' from the InstagramAPI class

bot = InstagramAPI(USERNAME,PASSWORD)

Up until this point of the script, we havn't actually communicated with instagrams server yet.

Finally we log in using the 'login()' function

bot.login()

Calling Functions Basic Usage

Every time we call a function using the api it will communicate with instagram using a 'session'

When we used the login() function essentially what it did was send a request to instagram's servers using fake headers to simulate us using a phone & our username/password. Once the login was complete instagram sent us back a response in json format.

We can view this response using

print bot.LastJson'

So we send a request using a function such as 'bot.login()' or 'bot.searchUsername('cats')' then instagram sends back a response in json format, Which is then stored in the 'bot.lastJson' variable.

Each time a new request is made the 'bot.lastJson' response is overwritten

Okay here's a sample script which will traverse and clean the response data from the 'bot.getUsernameInfo()' function

Be the First to Respond

Share Your Thoughts

  • Hot
  • Active