Skip to content

Instantly share code, notes, and snippets.

@JGallardo
Last active August 29, 2015 14:03
Show Gist options
  • Save JGallardo/d0f82c7ab809ada8fedd to your computer and use it in GitHub Desktop.
Save JGallardo/d0f82c7ab809ada8fedd to your computer and use it in GitHub Desktop.
script to get my the topics that I answer the most on Quora
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
def get_topics(user):
url = "http://www.quora.com/" + user + "/topics"
browser = webdriver.Chrome()
browser.get(url)
time.sleep(2)
bod = browser.find_element_by_tag_name("body")
get_topics('Juan-Gallardo')
no_of_pagedowns = 40
while no_of_pagedowns:
bod.send_keys(Keys.PAGE_DOWN)
time.sleep(0.3)
no_of_pagedowns-=1
topics = [t.text.encode('ascii', 'replace') for t in browser.find_elements_by_class_name("name_text")]
counts = [c.text.encode('ascii', 'replace').split(' ')[0] for c in browser.find_elements_by_class_name("name_meta")]
li = [[topics[i], int(counts[i])] for i in xrange(len(topics)) if counts[i] != '']
browser.quit()
return li
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment