Created
February 14, 2016 12:19
-
-
Save sousatg/68c712297a5e6785f03c to your computer and use it in GitHub Desktop.
Bot to follow followers of a twitter account
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from splinter import Browser | |
import csv, time | |
class TwitterAccount: | |
def __init__(self, username, password): | |
self.username = username | |
self.password = password | |
self.b = Browser() | |
self.doLogin() | |
def doLogin(self): | |
self.b.visit('https://twitter.com/') | |
self.b.find_by_xpath('//*[@id="signin-email"]').fill( self.username ) | |
self.b.find_by_xpath('//*[@id="signin-password"]').fill( self.password ) | |
self.b.find_by_xpath('//*[@id="front-container"]/div[2]/div[2]/form/table/tbody/tr/td[2]/button').click() | |
def doFollow(self, screen_name, num): | |
accountUrl = 'https://twitter.com/' + screen_name + '/followers' | |
self.b.visit( accountUrl ) | |
c = 0 | |
while True: | |
for btn in self.b.find_by_xpath('//button[contains(@class, "user-actions-follow-button")]'): | |
if btn.text == 'Seguir': | |
c = c + 1 | |
btn.click() | |
if c == num: | |
break | |
time.sleep(5) | |
def doQuit(self): | |
self.b.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment