Advertisement
Guest User

Untitled

a guest
Jun 14th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 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 = 'USERNAME HERE'
  10. insta_password = 'PASSWORD HERE'
  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=False)
  23.  
  24. try:
  25. session.login()
  26.  
  27. # settings
  28.  
  29. session.set_relationship_bounds(enabled=False,
  30. potency_ratio=-1.21,
  31. delimit_by_numbers=True,
  32. max_followers=4590,
  33. max_following=5555,
  34. min_followers=45,
  35. min_following=77)
  36. session.unfollow_users(amount=10, onlyInstapyFollowed = True, sleep_delay=10)
  37. session.follow_by_list(followlist=['carswithoutlimits', 'carlifestyle', 'millionaire_mentor', 'motivationmafia', 'businessmindset101', 'thebillionairesclub', 'millionaire.life.style', 'goodlife', 'thegoodlifeinc', 'onlyforluxury'], times=999, sleep_delay=60, interact=False)
  38. # actions
  39.  
  40. except Exception as exc:
  41. # if changes to IG layout, upload the file to help us locate the change
  42. if isinstance(exc, NoSuchElementException):
  43. file_path = os.path.join(gettempdir(), '{}.html'.format(time.strftime('%Y%m%d-%H%M%S')))
  44. with open(file_path, 'wb') as fp:
  45. fp.write(session.browser.page_source.encode('utf8'))
  46. print('{0}\nIf raising an issue, please also upload the file located at:\n{1}\n{0}'.format(
  47. '*' * 70, file_path))
  48. # full stacktrace when raising Github issue
  49. raise
  50.  
  51. finally:
  52. # end the bot session
  53. session.end()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement