Advertisement
Guest User

new-bot

a guest
Aug 13th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. from selenium import webdriver
  2. from time import sleep
  3. import random
  4. import time
  5. from selenium.webdriver.common.action_chains import ActionChains
  6.  
  7. file = open("list.txt", "r")
  8. read = file.readline()
  9. user = read.split(":")[0]
  10. password = read.split(":")[1]
  11. profile = webdriver.FirefoxProfile()
  12. profile.update_preferences()
  13.  
  14. '''
  15. # Set Tor/Socks5 Proxy
  16.  
  17. profile.set_preference( "network.proxy.socks_version", 5)
  18. profile.set_preference('network.proxy.type', 1)
  19. profile.set_preference('network.proxy.socks', '127.0.0.1')
  20. profile.set_preference('network.proxy.socks_port', 9150)
  21. profile.set_preference('network.proxy.socks_remote_dns', True)
  22. '''
  23.  
  24. '''
  25. # Set Http Proxy
  26.  
  27. profile.set_preference("network.proxy.type", 1)
  28. profile.set_preference("network.proxy.http", '127.0.0.1')
  29. profile.set_preference("network.proxy.http_port", int('80'))
  30. '''
  31.  
  32. '''
  33. # Set Https Proxy
  34.  
  35. profile.set_preference("network.proxy.type", 1)
  36. profile.set_preference("network.proxy.https", '127.0.0.1')
  37. profile.set_preference("network.proxy.http_port", int('8080'))
  38. '''
  39.  
  40. '''
  41. # Set User-agent
  42. file = open("user-agent.txt", "r")
  43. read = file.readline()
  44. profile.set_preference("general.useragent.override", read)
  45. '''
  46.  
  47. # Disable Cache
  48. profile.set_preference('browser.cache.disk.enable', False)
  49. profile.set_preference('browser.cache.memory.enable', False)
  50. profile.set_preference('browser.cache.offline.enable', False)
  51.  
  52. # Private Browser
  53. profile.set_preference("browser.privatebrowsing.autostart", True)
  54.  
  55. profile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so', False)
  56. profile.set_preference("media.peerconnection.enabled", False)
  57. profile.update_preferences()
  58. driver = webdriver.Firefox(profile)
  59.  
  60.  
  61. def Login():
  62. print("inter Login");
  63. driver.get('https://twitter.com/login?lang=en');
  64. sleep(1);
  65. emailInput = driver.find_element_by_xpath("//div[@id='page-container']/div/div/form/fieldset/div/input")
  66. for i in user:
  67. emailInput.send_keys(i)
  68. sleep(round(random.uniform(0.2, 0.7), 1))
  69. actions = ActionChains(driver)
  70. passwordInput = driver.find_element_by_xpath("//div[@id='page-container']/div/div/form/fieldset/div[2]/input")
  71. sleep(1.5)
  72. actions.click(passwordInput)
  73. for j in password:
  74. passwordInput.send_keys(j)
  75. sleep(round(random.uniform(0.2, 0.7), 1))
  76. submit = driver.find_element_by_xpath("//button[@type='submit']")
  77. actions.click(submit)
  78. actions.perform()
  79. sleep(15);
  80.  
  81.  
  82. def LikeTimeline():
  83. print("inter LikeTimeline");
  84. actions = ActionChains(driver)
  85. actions.send_keys('jl')
  86. actions.perform()
  87.  
  88. def ScrollTobottom():
  89. print("inter scroll");
  90. driver.execute_script("window.scrollBy(0," + str(random.randint(-750, 750)) + ")", "");
  91.  
  92.  
  93. def SleepForSomeTime():
  94. print("inter sleep");
  95. sleep(random.randint(0, 15));
  96.  
  97.  
  98. def Refresh():
  99. print("inter refresh");
  100. driver.refresh();
  101.  
  102.  
  103. def Follow():
  104. profileArray = [];
  105. murl = [];
  106. profileArray = driver.find_elements_by_xpath(
  107. "//a[contains(@class, 'account-group js-account-group js-action-profile js-user-profile-link js-nav')]");
  108. for url in profileArray:
  109. murl.append(url.get_attribute("href"))
  110. for url in murl:
  111. print(url);
  112. driver.get(url);
  113. navs = driver.find_elements_by_xpath("//span[contains(@class, 'ProfileNav-value')]");
  114. followers_count = navs[2].get_attribute("data-count");
  115. if (followers_count > 500 and random.randint(1, 15) > 7):
  116. try:
  117. flwButton = driver.find_element_by_xpath("//button[contains(@class, 'follow-text')]");
  118. flwButton.click();
  119. sleep(5);
  120. except:
  121. continue;
  122.  
  123.  
  124. #########################################################################################
  125. ############ ############
  126. ############ ############
  127. ############ ############
  128. ############ ############
  129. ############ ############
  130. ############ ############
  131. #########################################################################################
  132. random.seed(time.clock())
  133.  
  134. driver.delete_all_cookies();
  135. Login();
  136. LikeTimeline();
  137. #Follow();
  138. # ScrollTobottom();
  139. # Refresh();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement