Skip to content

Instantly share code, notes, and snippets.

@rmcgibbo
Created October 30, 2012 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rmcgibbo/3979486 to your computer and use it in GitHub Desktop.
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
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