Skip to content

Instantly share code, notes, and snippets.

@focaalvarez
Created November 12, 2020 12:06
Show Gist options
  • Select an option

  • Save focaalvarez/5e331c43a77b764a4ecf437364b2bcd7 to your computer and use it in GitHub Desktop.

Select an option

Save focaalvarez/5e331c43a77b764a4ecf437364b2bcd7 to your computer and use it in GitHub Desktop.
from instapy import InstaPy
from instapy import smart_run
import pandas as pd
# login credentials
insta_username = #your user name
insta_password = #your password
# get an InstaPy session!
session = InstaPy(username=insta_username,
password=insta_password,
headless_browser=False)
my_followers=['sugarandmountains','chartrdaily','fanmaps']
df=pd.DataFrame(columns=['user','following'])
with smart_run(session):
#General settings
session.set_skip_users(skip_private=True,skip_no_profile_pic=True)
session.set_relationship_bounds(enabled=True, potency_ratio=None, delimit_by_numbers=True, max_following=5000, min_followers=100,min_posts=10)
#Activity Flow
for i in my_followers: #for complete list of following, set amount='full'
account_following = session.grab_following(username=i, amount=5000, live_match=False, store_locally=True)
df2=pd.DataFrame(columns=['user','following'])
df2['following']=account_following
df2['user']=i
df=pd.concat([df, df2],ignore_index=True)
df.to_csv('relationships.csv')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment