Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. # bot/insta_spammer/main.py
  2. # bot/Pipfile
  3. '''
  4. [[source]]
  5. name = "pypi"
  6. url = "https://pypi.org/simple"
  7. verify_ssl = true
  8.  
  9. [dev-packages]
  10.  
  11. [packages]
  12. instapy = {editable = true,git = "https://github.com/timgrossmann/InstaPy.git"}
  13. schedule = "*"
  14.  
  15. [requires]
  16. python_version = "3.7"
  17. '''
  18.  
  19. import time
  20.  
  21. import schedule
  22. from instapy import InstaPy
  23. from instapy.util import smart_run
  24.  
  25. AMOUNT_OF_COMMENTS_PER_SESSION = 100
  26.  
  27. # login credentials
  28. INSTA_USERNAME = ''
  29. INSTA_PASSWORD = ''
  30.  
  31. CITY = '' # required city
  32.  
  33. AMOUNT_OF_RUNS = 1
  34. DELAY_INTERVAL = 14 # in minutes
  35. MESSAGES_TO_SEND = ['какой милый пёсик']
  36.  
  37. cities = {
  38. 'city_1': ['17326249', '359545221', '156928551799991', ], # Москва
  39. 'city_2': ['213174824', '214568397', '709060089', ], # Санкт-Петербург
  40. 'city_3': ['215711407', '1161320117280403', '607002406', ], # Новосибирск
  41. 'city_4': ['614466567', '221661431', '1393125210716088', ], # Екатеринбург
  42. 'city_5': ['219244324', '286314068', ], # Нижний Новгород
  43. 'city_6': ['221630742', '730750789', ], # Казань
  44. 'city_7': ['393591894', '715206142', ], # Челябинск
  45. 'city_8': ['225842991', ], # Омск
  46. 'city_9': ['214290799', '213094418', ], # Самара
  47. 'city_10': ['329124836', '221038870', ], # Ростов-на-Дону
  48. 'city_11': ['221130590', '751273342', ], # Уфа
  49. 'city_12': ['217382401', '506820667', ], # Красноярск
  50. 'city_13': ['213735459', '1763202587236611', ], # Пермь
  51. 'city_14': ['223125721', '279896232', ], # Воронеж
  52. 'city_15': ['228380188', '736990561', ], # Волгоград
  53. 'city_16': ['213742796', '894812510', '567476175', '787502271', '262176779'], # Краснодар
  54. 'city_17': ['383772834', '554931143'], # Саратов
  55. 'city_18': ['215031298', '289954068', ], # Тюмень
  56. }
  57.  
  58. def job():
  59. try:
  60. # get an InstaPy session!
  61. # set headless_browser=True to run InstaPy in the background
  62. session = InstaPy(username=INSTA_USERNAME,
  63. password=INSTA_PASSWORD,
  64. headless_browser=False)
  65. with smart_run(session):
  66. """ Activity flow """
  67. # settings
  68. session.set_do_comment(True, percentage=100)
  69. session.set_comments(MESSAGES_TO_SEND)
  70. session.comment_by_locations(cities[CITY], amount=AMOUNT_OF_COMMENTS_PER_SESSION)
  71. except:
  72. import traceback
  73. print(traceback.format_exc())
  74.  
  75.  
  76. schedule.every().minutes(DELAY_INTERVAL).do(job)
  77.  
  78.  
  79. def main():
  80. for i in range(AMOUNT_OF_RUNS):
  81. schedule.run_pending()
  82. time.sleep(1)
  83.  
  84.  
  85. if __name__ == '__main__':
  86. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement