Created
December 13, 2018 10:11
-
-
Save tariquesani/ea1e3d287757df9e4b4474d89683422a to your computer and use it in GitHub Desktop.
A wee bit complex InstaPy script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import traceback | |
import sys | |
import requests | |
from instapy import InstaPy | |
from instapy.util import smart_run | |
from tendo import singleton | |
bot = singleton.SingleInstance() # will sys.exit(-1) if other instance is running | |
# login credentials | |
insta_username = '' | |
insta_password = '' | |
url = 'https://www.instagram.com/' + insta_username | |
r = requests.get(url).text | |
start_b = '"edge_follow":{"count":' | |
end_b = '},"follows_viewer"' | |
following = int((r[r.find(start_b)+len(start_b):r.rfind(end_b)])) | |
dont_likes = [] | |
friends = [] | |
like_tag_list = [] | |
ignore_list = [] | |
accounts = [] | |
business_categories = [] | |
if following < 1200: | |
print('You follow less than 1200 users. Precisely, ' + str(following) + '. Starting follow and like session.') | |
def get_session(): | |
session = InstaPy(username=insta_username, | |
password=insta_password, | |
headless_browser=True, | |
nogui=True, | |
multi_logs=False) | |
return session | |
def session(): | |
# get a session! | |
session = get_session() | |
# let's go! | |
with smart_run(session): | |
try: | |
session.set_relationship_bounds(enabled=True, | |
potency_ratio=None, | |
delimit_by_numbers=True, | |
max_followers=6000, | |
max_following=3000, | |
min_followers=30, | |
min_following=30) | |
session.set_quota_supervisor(enabled=True, sleep_after=["likes", "comments_d", "follows", "unfollows", "server_calls_h"], sleepyhead=True, stochastic_flow=True, notify_me=True, | |
peak_likes=(150, 1000), | |
peak_comments=(35, 250), | |
peak_follows=(60, 500), | |
peak_unfollows=(60, 500), | |
peak_server_calls=(None, None)) | |
session.set_skip_users(skip_private=True, | |
private_percentage=100, | |
skip_no_profile_pic=True, | |
no_profile_pic_percentage=80, | |
skip_business=True, | |
business_percentage=80, | |
skip_business_categories=[], | |
dont_skip_business_categories=[business_categories]) | |
session.set_dont_include(friends) | |
session.set_dont_like(dont_likes) | |
session.set_ignore_if_contains(ignore_list) | |
session.set_delimit_liking(enabled=True, max=random.randint(10,75), min=None) | |
session.set_user_interact(amount=2, randomize=True, percentage=60) | |
session.set_do_follow(enabled=True, percentage=60) | |
session.set_do_like(enabled=True, percentage=80) | |
# actions | |
session.like_by_tags(random.sample(like_tag_list, 5), amount=random.randint(50, 100), interact=True) | |
session.follow_commenters([similarusers], amount=randint(75,150), daysold=365, max_pic = 100, sleep_delay=600, interact=True) | |
session.follow_by_tags(random.sample(like_tag_list, 5), amount=randint(75,150)) | |
session.unfollow_users(amount=random.randint(75,150), InstapyFollowed=(True, "nonfollowers"), style="FIFO", unfollow_after=24*60*60, sleep_delay=501) | |
except Exception: | |
print(traceback.format_exc()) | |
session() | |
else: | |
print('You follow more than 1200 users. Precisely, ' + str(following) + '. Starting clean up session.') | |
def get_session(): | |
session = InstaPy(username=insta_username, | |
password=insta_password, | |
headless_browser=True, | |
nogui=True, | |
multi_logs=False) | |
return session | |
def session(): | |
# get a session! | |
session = get_session() | |
# let's go! | |
with smart_run(session): | |
try: | |
session.set_quota_supervisor(enabled=True, sleep_after=["likes", "comments_d", "follows", "unfollows", "server_calls_h"], sleepyhead=True, stochastic_flow=True, notify_me=True, | |
peak_likes=(None, None), | |
peak_comments=(None, None), | |
peak_follows=(None, None), | |
peak_unfollows=(100, 600), | |
peak_server_calls=(None, None)) | |
session.set_dont_include(friends) | |
session.unfollow_users(amount=random.randint(350,600), allFollowing=True, style="FIFO", unfollow_after=1*1*60, sleep_delay=501) | |
except Exception: | |
print(traceback.format_exc()) | |
session() | |
print('Session end') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment