MCPcopy
hub / github.com/InstaPy/InstaPy / get_following

Function get_following

instapy/relationship_tools.py:326–616  ·  view source on GitHub ↗

Get entire list of following using graphql queries.

(
    browser,
    self_username,
    username,
    grab,
    relationship_data,
    live_match,
    store_locally,
    logger,
    logfolder,
)

Source from the content-addressed store, hash-verified

324
325
326def get_following(
327 browser,
328 self_username,
329 username,
330 grab,
331 relationship_data,
332 live_match,
333 store_locally,
334 logger,
335 logfolder,
336):
337 """Get entire list of following using graphql queries."""
338
339 # Variables
340 user_data = {}
341 variables = {}
342
343 if username not in relationship_data:
344 relationship_data.update({username: {"all_following": [], "all_followers": []}})
345
346 grab_info = (
347 'at "full" range' if grab == "full" else "at the range of {}".format(grab)
348 )
349 tense = (
350 "live"
351 if (live_match is True or not relationship_data[username]["all_following"])
352 else "fresh"
353 )
354
355 logger.info(
356 "Retrieving {} `Following` data of {} {}".format(tense, username, grab_info)
357 )
358
359 user_link = "https://www.instagram.com/{}/".format(username)
360 web_address_navigator(browser, user_link)
361
362 # Get following count
363 _, following_count = get_relationship_counts(browser, username, logger)
364
365 if grab != "full" and grab > following_count:
366 logger.info(
367 "You have requested higher amount than existing following count "
368 " ~gonna grab all available"
369 )
370 grab = following_count
371
372 # Check if user's account is private and we don't follow
373 following_status, _ = get_following_status(
374 browser, "profile", self_username, username, None, logger, logfolder
375 )
376
377 is_private = is_private_profile(browser, logger, following_status == "Following")
378 if not username == self_username and (
379 is_private is None
380 or (is_private is True and following_status not in ["Following", True])
381 or (following_status == "Blocked")
382 ):
383 logger.info(

Callers 6

unfollowFunction · 0.85
grab_followingMethod · 0.85
get_unfollowersFunction · 0.85
get_nonfollowersFunction · 0.85
get_fansFunction · 0.85
get_mutual_followingFunction · 0.85

Calls 10

web_address_navigatorFunction · 0.85
get_relationship_countsFunction · 0.85
get_following_statusFunction · 0.85
is_private_profileFunction · 0.85
interruption_handlerFunction · 0.85
progress_trackerFunction · 0.85
truncate_floatFunction · 0.85
sleepFunction · 0.85
store_following_dataFunction · 0.85
execute_scriptMethod · 0.80

Tested by

no test coverage detected