Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import time
- from tempfile import gettempdir
- from selenium.common.exceptions import NoSuchElementException
- from instapy import InstaPy
- insta_username = 'pop'
- insta_password = 'floren'
- # set headless_browser=True if you want to run InstaPy on a server
- # set these in instapy/settings.py if you're locating the
- # library in the /usr/lib/pythonX.X/ directory:
- # Settings.database_location = '/path/to/instapy.db'
- # Settings.chromedriver_location = '/path/to/chromedriver'
- session = InstaPy(username=insta_username,
- password=insta_password,
- headless_browser=True,
- multi_logs=True,bypass_suspicious_attempt=False)
- try:
- session.login()
- # settings
- session.set_relationship_bounds(enabled=True,
- potency_ratio=-0.70,
- delimit_by_numbers=True,
- max_followers=4590,
- max_following=5555,
- min_followers=30,
- min_following=30)
- session.set_do_comment(False, percentage=10)
- session.set_comments(['aMEIzing!', 'So much fun!!', 'Nicey!'])
- session.set_dont_include(['friend1', 'friend2', 'friend3'])
- session.set_dont_like(['pizza'])
- session.set_do_follow(enabled=True, percentage=70, times=1)
- # actions
- session.follow_likers (['aldea.aa' , 'bghac' , 'sam.ioana' , 'roxanamisaila' , 'maratancu'], photo_grab_amount=4, follow_likers_per_photo=20, randomize=False, sleep_delay=10, interact=False)
- session.unfollow_users(amount=400, nonFollowers=True, style="RANDOM", unfollow_after=42*60*60, sleep_delay=60)
- session.set_dont_unfollow_active_users(enabled=True, posts=5)
- session.like_by_locations(['498456079'], amount=100)
- session.like_by_feed(amount=100, randomize=True, unfollow=True, interact=True)
- except Exception as exc:
- # if changes to IG layout, upload the file to help us locate the change
- if isinstance(exc, NoSuchElementException):
- file_path = os.path.join(gettempdir(), '{}.html'.format(time.strftime('%Y%m%d-%H%M%S')))
- with open(file_path, 'wb') as fp:
- fp.write(session.browser.page_source.encode('utf8'))
- print('{0}\nIf raising an issue, please also upload the file located at:\n{1}\n{0}'.format(
- '*' * 70, file_path))
- # full stacktrace when raising Github issue
- raise
- finally:
- # end the bot session
- session.end()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement