Skip to content

Instantly share code, notes, and snippets.

@hancush
Last active September 29, 2015 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hancush/3194a18ae8b374ca735d to your computer and use it in GitHub Desktop.
Save hancush/3194a18ae8b374ca735d to your computer and use it in GitHub Desktop.
# WARNING: THIS SCRIPT VIOLATES TWITTER'S TOS, USE AT YOUR OWN RISK
import tweepy
from config import *
import urllib2
import pprint
import requests
requests.packages.urllib3.disable_warnings()
auth = tweepy.OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)
api = tweepy.API(auth_handler=auth)
pages = { # assigns values to URLs of raw list files
"1":"https://raw.githubusercontent.com/amirahaile/Amazing-Women-on-Twitter/master/ladiesA-D.md",
"2":"https://raw.githubusercontent.com/amirahaile/Amazing-Women-on-Twitter/master/ladiesE-L.md",
"3":"https://raw.githubusercontent.com/amirahaile/Amazing-Women-on-Twitter/master/ladiesM-Z.md"
}
print """
So ya want to follow some awesome tech ladies?
These are the lists:
1 - A thru D
2 - E thru L
3 - M thru Z
"""
page = pages[raw_input("Which list should I parse for handles? ")] # converts entered value to URL
file = urllib2.urlopen(page) # variable containing open URL contained in page
them = [line.partition("[@")[2].partition("]")[0] for line in file if "[@" in line] # pulls handles from file
followed = []
to_follow = []
print "Parsing file. I'd suggest a Beyonce track while you wait!"
for her in them:
user = api.get_user(her)
if user.follow_request_sent is True: # adds users you've already requested to follow to followed
followed.append(her)
elif user.following is False: # adds users you don't follow to to_follow
to_follow.append(her)
else: # adds users you already follow to followed
followed.append(her)
print "You already follow these ladies:"
pprint.pprint(followed)
print "Follow these ladies?"
pprint.pprint(to_follow)
answer = str(raw_input("Y or N? ")).lower()
if answer == "y":
for her in to_follow:
api.create_friendship(her) # this is technically against the rules
else:
print "No problem."
print "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment