Skip to content

Instantly share code, notes, and snippets.

@AlexanderProd
Last active December 16, 2018 08:57
Show Gist options
  • Save AlexanderProd/10065dbcf5eeee188e3e7ab1be53afec to your computer and use it in GitHub Desktop.
Save AlexanderProd/10065dbcf5eeee188e3e7ab1be53afec to your computer and use it in GitHub Desktop.
Script for InstaPy
# imports
from instapy import InstaPy
from instapy.util import smart_run
import json
import time
import schedule
# login credentials
insta_username = '*********'
insta_password = '*********'
with open('blacklist.json', mode='r', encoding='UTF-8') as blacklistFile:
blacklist = json.load(blacklistFile)
def unfollow():
# get an InstaPy session!
# set headless_browser=True to run InstaPy in the background
session = InstaPy(username=insta_username, password=insta_password, headless_browser=True, nogui=True)
with smart_run(session):
""" Activity flow """
# settings
session.set_dont_include(blacklist)
# actions
session.unfollow_users(amount=200, allFollowing=True, style="FIFO", unfollow_after=24*60*60, sleep_delay=40)
def followByList():
session = InstaPy(username=insta_username, password=insta_password, headless_browser=True, nogui=True)
with smart_run(session):
""" Activty flow """
# settings
session.set_skip_users(skip_private=False, private_percentage=100)
session.set_relationship_bounds(enabled=False)
#actions
session.follow_by_list(blacklist, times=1, sleep_delay=40, interact=False)
def follow():
session = InstaPy(username=insta_username, password=insta_password, headless_browser=True, nogui=True)
with smart_run(session):
""" Activty flow """
# settings
session.set_skip_users(skip_private=False, private_percentage=100)
session.set_relationship_bounds(enabled=False)
#actions
session.follow_user_followers(['1_fc_nuernberg', 'nuernberg_de', 'energynuernberg'], amount=150, randomize=True, sleep_delay=40)
def likeByTags():
session = InstaPy(username=insta_username, password=insta_password, headless_browser=True, nogui=True)
with smart_run(session):
""" Activity flow """
session.set_relationship_bounds(enabled=False)
session.set_user_interact(amount=3, randomize=True, percentage=100, media='Photo')
#actions
session.like_by_tags(['nürnberg', 'nuremberg', 'fcn'], amount=50, interact=True)
#schedule.every().day.at("06:00").do(exit)
schedule.every().day.at("08:00").do(follow)
schedule.every().day.at("09:00").do(follow)
schedule.every().day.at("10:00").do(follow)
schedule.every().day.at("11:00").do(follow)
schedule.every().day.at("12:00").do(follow)
schedule.every().day.at("13:00").do(follow)
schedule.every().day.at("14:00").do(follow)
schedule.every().day.at("15:00").do(follow)
schedule.every().day.at("16:00").do(follow)
schedule.every().day.at("17:00").do(follow)
schedule.every().day.at("18:00").do(follow)
schedule.every().day.at("19:00").do(follow)
schedule.every().day.at("20:00").do(follow)
schedule.every().day.at("21:00").do(unfollow)
schedule.every().day.at("22:00").do(unfollow)
schedule.every().day.at("23:00").do(unfollow)
schedule.every().day.at("00:00").do(unfollow)
schedule.every().day.at("01:00").do(unfollow)
schedule.every().day.at("02:00").do(unfollow)
schedule.every().day.at("03:00").do(unfollow)
schedule.every().day.at("04:00").do(unfollow)
schedule.every().day.at("05:00").do(unfollow)
while True:
schedule.run_pending()
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment