Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.75 KB | None | 0 0
  1. # VERSION 0.1.9.1
  2.  
  3. from art import *
  4. import pandas as pd
  5. import random
  6. from random import randint
  7. from time import sleep, strftime
  8. import selenium
  9. from selenium import webdriver
  10. from selenium.common.exceptions import NoSuchElementException
  11. from selenium.common.exceptions import StaleElementReferenceException
  12. from selenium.webdriver.common.by import By
  13. from selenium.webdriver.support import expected_conditions as EC
  14. from selenium.webdriver.support import ui
  15. from selenium.webdriver.common.action_chains import ActionChains
  16. from selenium.webdriver.common.keys import Keys
  17. from tqdm import tqdm
  18. from tqdm import tqdm_gui
  19. import sys
  20. sys.path.insert(0, './utils/')
  21. import secret
  22. import hashtags
  23. import userlist
  24. import limits
  25. import proxy
  26. import warnings
  27. import datetime
  28.  
  29. tprint("Welcome OGU")
  30. sleep(0.5)
  31. print("Made with Selenium")
  32. sleep(0.5)
  33. print("Version 0.1.9.1")
  34. print("Loading Scripts...")
  35. time_start = datetime.datetime.now()
  36. for i in tqdm(range(6)):
  37. sleep(0.05)
  38. pass
  39.  
  40.  
  41. use_proxy = input("Do you want to use a proxy? [y/n]: ")
  42.  
  43. if use_proxy == "y":
  44. use_proxy_config = input("Do you want to use the proxy config file? [y/n]: ")
  45. if use_proxy_config == "n":
  46. proxy_type = input("IP:PORT only? [y/n]: ")
  47. if proxy_type == "n":
  48. proxy_username = input("Enter your proxy username: ")
  49. proxy_password = input("Enter your proxy passowrd: ")
  50. proxy_host = input("Enter your proxy host (ip:port): ")
  51. from selenium.webdriver.firefox.options import Options
  52. from seleniumwire import webdriver
  53. #options = webdriver.ChromeOptions()
  54.  
  55. options = {
  56. 'proxy': {
  57. 'http': 'http://{}:{}@{}'.format(proxy_username, proxy_password, proxy_host),
  58. 'https': 'https://{}:{}@{}'.format(proxy_username, proxy_password, proxy_host)
  59. }
  60. }
  61. ##options.add_argument("--mute-audio")
  62. warnings.filterwarnings("ignore", category=DeprecationWarning)
  63. profile = webdriver.FirefoxProfile()
  64. profile.set_preference("media.volume_scale", "0.0")
  65. ##webdriver = webdriver.Chrome(seleniumwire_options=options, chrome_options=options, executable_path='./chromedriver')
  66. webdriver = webdriver.Firefox(seleniumwire_options=options, firefox_options=options, executable_path="./geckodriver", firefox_profile=profile)
  67. sleep(2)
  68. webdriver.get('https://www.instagram.com/accounts/login/?source=auth_switcher')
  69. sleep(3)
  70. else:
  71. proxy_host = input("Enter your proxy IP:PORT: ")
  72. from selenium.webdriver.firefox.options import Options
  73. #options = webdriver.ChromeOptions()
  74.  
  75. warnings.filterwarnings("ignore", category=DeprecationWarning)
  76. options.add_argument('--proxy-server={}'.format(proxy_host))
  77. ##options.add_argument("--mute-audio")
  78. profile = webdriver.FirefoxProfile()
  79. profile.set_preference("media.volume_scale", "0.0")
  80. ##webdriver = webdriver.Chrome(chrome_options=options, executable_path='./chromedriver')
  81. webdriver = webdriver.Firefox(firefox_options=options, executable_path="./geckodriver", firefox_profile=profile)
  82. sleep(2)
  83. webdriver.get('https://www.instagram.com/accounts/login/?source=auth_switcher')
  84. sleep(3)
  85. else:
  86. proxy_type = input("IP:PORT only? [y/n]: ")
  87. if proxy_type == "n":
  88. from selenium.webdriver.firefox.options import Options
  89. from seleniumwire import webdriver
  90. #options = webdriver.ChromeOptions()
  91.  
  92. options = {
  93. 'proxy': {
  94. 'http': 'http://{}:{}@{}'.format(proxy.proxy_username, proxy.proxy_password, proxy.proxy_host),
  95. 'https': 'https://{}:{}@{}'.format(proxy.proxy_username, proxy.proxy_password, proxy.proxy_host)
  96. }
  97. }
  98. ##options.add_argument("--mute-audio")
  99. warnings.filterwarnings("ignore", category=DeprecationWarning)
  100. profile = webdriver.FirefoxProfile()
  101. profile.set_preference("media.volume_scale", "0.0")
  102. ##webdriver = webdriver.Chrome(seleniumwire_options=options, chrome_options=options, executable_path='./chromedriver')
  103. webdriver = webdriver.Firefox(seleniumwire_options=options, firefox_options=options, executable_path="./geckodriver", firefox_profile=profile)
  104. sleep(2)
  105. webdriver.get('https://www.instagram.com/accounts/login/?source=auth_switcher')
  106. sleep(3)
  107. else:
  108. from selenium.webdriver.firefox.options import Options
  109. #options = webdriver.ChromeOptions()
  110.  
  111. warnings.filterwarnings("ignore", category=DeprecationWarning)
  112. options.add_argument('--proxy-server={}'.format(proxy.proxy_host))
  113. ##options.add_argument("--mute-audio")
  114. profile = webdriver.FirefoxProfile()
  115. profile.set_preference("media.volume_scale", "0.0")
  116. ##webdriver = webdriver.Chrome(chrome_options=options, executable_path='./chromedriver')
  117. webdriver = webdriver.Firefox(firefox_options=options, executable_path="./geckodriver", firefox_profile=profile)
  118. sleep(2)
  119. webdriver.get('https://www.instagram.com/accounts/login/?source=auth_switcher')
  120. sleep(3)
  121. else:
  122. profile = webdriver.FirefoxProfile()
  123. profile.set_preference("media.volume_scale", "0.0")
  124. ##options = webdriver.ChromeOptions()
  125. ##options.add_argument("--mute-audio")
  126. ##webdriver = webdriver.Chrome(executable_path='./chromedriver')
  127. webdriver = webdriver.Firefox(executable_path="./geckodriver", firefox_profile=profile)
  128. sleep(2)
  129. webdriver.get('https://www.instagram.com/accounts/login/?source=auth_switcher')
  130. sleep(3)
  131. username = webdriver.find_element_by_name('username')
  132. username.send_keys(secret.username)
  133. password = webdriver.find_element_by_name('password')
  134. password.send_keys(secret.password)
  135. sleep(2)
  136. button_login = webdriver.find_element_by_xpath(
  137. '/html/body/div[1]/section/main/div/article/div/div[1]/div/form/div[4]/button')
  138. button_login.click()
  139. sleep(10)
  140.  
  141. try:
  142. notnow = webdriver.find_element_by_css_selector(
  143. 'button.aOOlW:nth-child(2)')
  144. notnow.click() # comment these last 2 lines out, if you don't get a pop up asking about notifications
  145. except NoSuchElementException:
  146. pass
  147.  
  148. num = 0
  149. for user in userlist.users:
  150. sleep(2)
  151. webdriver.get('https://www.instagram.com/' +
  152. userlist.users[num] + '/')
  153. sleep(5)
  154. print("Getting followers with Stories to watch from: {}".format(userlist.users[num]))
  155. num += 1
  156. sleep(1)
  157. followers_list__open = webdriver.find_element_by_xpath('/html/body/div[1]/section/main/div/header/section/ul/li[2]/a')
  158. followers_list__open.click()
  159. sleep(2)
  160.  
  161. fBody = webdriver.find_element_by_xpath("//div[@class='isgrP']")
  162. scroll = 0
  163. while scroll < limits.scroll_amount: # scroll 5 times
  164. webdriver.execute_script('arguments[0].scrollTop = arguments[0].scrollTop + arguments[0].offsetHeight;', fBody)
  165. sleep(2)
  166. scroll += 1
  167.  
  168. fList = webdriver.find_elements_by_xpath("//div[@class='isgrP']//li")
  169.  
  170. wbList = webdriver.find_elements_by_xpath("//div[@class='RR-M- h5uC0 SAvC5']")
  171. print("Users found with Story to watch: {}".format(len(wbList)))
  172. story_watching_done = 'false'
  173. stories_next_watch = "true"
  174. story_watching_counter = 0
  175. stories_bf_watched = 1
  176.  
  177. try:
  178. for user_story in wbList:
  179. while story_watching_done == 'false':
  180. stories_next_watch = "true"
  181. wbList = webdriver.find_elements_by_xpath("//div[@class='RR-M- h5uC0 SAvC5']")
  182. webdriver.execute_script("arguments[0].scrollIntoView();", wbList[story_watching_counter])
  183. wbList[story_watching_counter].click()
  184. while stories_next_watch == "true":
  185. try:
  186. sleep(randint(2, 3))
  187. webdriver.implicitly_wait(2)
  188. watch_all_stories_next = webdriver.find_element_by_css_selector(".ow3u_").click()
  189. stories_bf_watched += 1
  190. print("Stories watched from followers: {}".format(stories_bf_watched))
  191. except (NoSuchElementException, StaleElementReferenceException) as e:
  192. stories_next_watch = "false"
  193.  
  194. else:
  195. try:
  196. watch_all_stories_close_from_followers = webdriver.find_element_by_xpath("/html/body/div[1]/section/div/div/section/div[2]/button[3]/div")
  197. watch_all_stories_close_from_followers.click()
  198. except NoSuchElementException:
  199. pass
  200. wbList = webdriver.find_elements_by_xpath("//div[@class='RR-M- h5uC0 SAvC5']")
  201. story_watching_counter += 1
  202. sleep(1)
  203. else:
  204. pass
  205. except IndexError as error:
  206. print("Index Error..")
  207. print("Moving to next user...")
  208. pass
  209. else:
  210. print("Script finished!")
  211. time_end = datetime.datetime.now()
  212. sleep(1)
  213. print ("Script Started at: {}".format(time_start.strftime("%Y-%m-%d %H:%M:%S")))
  214. sleep(1)
  215. print ("Script Ended at: {}".format(time_end.strftime("%Y-%m-%d %H:%M:%S")))
  216. sleep(1)
  217. print("Total Stories watched from users followers: {}".format(limits.user_watch_followers_stories, stories_bf_watched))
  218. sleep(1)
  219. print("closing browser...")
  220. sleep(1)
  221. webdriver.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement