0

I am trying to understand a Python package called Instaloader and how many requests are actually being made to the Instagram server. With Instaloader, one can create a Profile instance from a given username with the following snippet of code:

loader = Instaloader()
loader.load_session_from_file(login_name)
profile = Profile.from_username(loader.context, target_profile) 

Q1. Am I correct in assuming the last line makes a single request to the Instagram server? Am I also correct in assuming I am creating a data object (and not a reference) that is being stored in the "profile" variable?

profile_full_name = profile.full_name

Q2. Am I correct in assuming this does not make a request to the server, but retrieves a parameter from the data object in the profile variable?

followers = profile.get_followers()

Q3. Am I correct in assuming this makes another request to the server and stores the data object in the "followers" variable? The documentation says the return type is "NodeIterator[Profile]". Does this mean I am storing the data object for each profile from the target's followers? Or am I making a reference to each of those profiles?

Q4. If I am storing the data object for each profile, does that mean extracting information from the data object for these profiles will NOT make additional requests to the server? (Because I already have it stored in the "followers" variable?)

Or does it operate as a reference and thus: each moment I extract additional parameters from a follower profile, it will require an additional request to the server?

1 Answers1

0

These answers were provided to me elsewhere:

A1. Yes, Profile.from_username() does make a single request to Instagram, which contains most of the profile metadata, and returns a Profile instance with that data included.

A2. Yes, full_name is already included in the data structure returned by Profile.from_username() and accessing it will in this case not trigger any further requests.

A3 & A4. get_followers() makes one request to the server and returns a NodeIterator. Some of the followers are already included with a thin data structure, containing only basic information. Iterating this iterator or accessing the items it yields will trigger further requests as required.