Created
October 30, 2012 10:29
-
-
Save rmcgibbo/3979486 to your computer and use it in GitHub Desktop.
Follow all of the top writers on Quora with a python/selenium/chrome hack
This file contains hidden or 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 selenium import webdriver | |
import time | |
import random | |
import numpy as np | |
browser = webdriver.Chrome() | |
browser.get('https://www.quora.com/login') | |
raw_input('You need to log in in the browser window. Hit enter here when finished...') | |
browser.get('http://www.quora.com/Top-Writers-on-Quora/Who-is-in-Top-Writers-2012') | |
num_top_users = len(browser.find_element_by_id('answer_wiki').find_elements_by_tag_name('li')) | |
for i in np.random.permutation(num_top_users): | |
li = browser.find_element_by_id('answer_wiki').find_elements_by_tag_name('li')[i] | |
li.find_element_by_tag_name('a').click() | |
fb = browser.find_element_by_class_name('follow_button') | |
if fb.is_displayed() and fb.text != 'Unfollow': | |
fb.click() | |
# be nice to quora and sleep a little bit between requests | |
time.sleep(10*np.random.rand()) | |
browser.back() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment