Advertisement
Guest User

Untitled

a guest
Aug 29th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. import os
  2. import time
  3. from tempfile import gettempdir
  4.  
  5. from selenium.common.exceptions import NoSuchElementException
  6.  
  7. from instapy import InstaPy
  8.  
  9. insta_username = 'pop'
  10. insta_password = 'floren'
  11.  
  12. # set headless_browser=True if you want to run InstaPy on a server
  13.  
  14. # set these in instapy/settings.py if you're locating the
  15. # library in the /usr/lib/pythonX.X/ directory:
  16. # Settings.database_location = '/path/to/instapy.db'
  17. # Settings.chromedriver_location = '/path/to/chromedriver'
  18.  
  19. session = InstaPy(username=insta_username,
  20. password=insta_password,
  21. headless_browser=True,
  22. multi_logs=True,bypass_suspicious_attempt=False)
  23.  
  24. try:
  25. session.login()
  26. # settings
  27. session.set_relationship_bounds(enabled=True,
  28. potency_ratio=-0.70,
  29. delimit_by_numbers=True,
  30. max_followers=4590,
  31. max_following=5555,
  32. min_followers=30,
  33. min_following=30)
  34. session.set_do_comment(False, percentage=10)
  35. session.set_comments(['aMEIzing!', 'So much fun!!', 'Nicey!'])
  36. session.set_dont_include(['friend1', 'friend2', 'friend3'])
  37. session.set_dont_like(['pizza'])
  38. session.set_do_follow(enabled=True, percentage=70, times=1)
  39. # actions
  40. 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)
  41. session.unfollow_users(amount=400, nonFollowers=True, style="RANDOM", unfollow_after=42*60*60, sleep_delay=60)
  42. session.set_dont_unfollow_active_users(enabled=True, posts=5)
  43. session.like_by_locations(['498456079'], amount=100)
  44. session.like_by_feed(amount=100, randomize=True, unfollow=True, interact=True)
  45. except Exception as exc:
  46. # if changes to IG layout, upload the file to help us locate the change
  47. if isinstance(exc, NoSuchElementException):
  48. file_path = os.path.join(gettempdir(), '{}.html'.format(time.strftime('%Y%m%d-%H%M%S')))
  49. with open(file_path, 'wb') as fp:
  50. fp.write(session.browser.page_source.encode('utf8'))
  51. print('{0}\nIf raising an issue, please also upload the file located at:\n{1}\n{0}'.format(
  52. '*' * 70, file_path))
  53. # full stacktrace when raising Github issue
  54. raise
  55.  
  56. finally:
  57. # end the bot session
  58. session.end()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement