Skip to content

Instantly share code, notes, and snippets.

@pdparker
Last active August 29, 2015 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdparker/dc5967eb7cad44aa157a to your computer and use it in GitHub Desktop.
Save pdparker/dc5967eb7cad44aa157a to your computer and use it in GitHub Desktop.
GS citation profile for conky or geektools
#load beautiful soup and itertools
from bs4 import BeautifulSoup
import itertools
import re
from urllib import FancyURLopener
class MyOpener(FancyURLopener):
version = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36'
openurl = MyOpener().open
#If you want to use you will have to change "user=*" in the url below
url = 'http://scholar.google.com.au/citations?user=xHY4MJ8AAAAJ&hl=en'
url = url + '&view_op=list_works&sortby=pubdate&cstart=0&pagesize=1000'
soup = BeautifulSoup(openurl(url).read())
#extract career record
career = soup.findAll("td", { "class" : "gsc_rsb_std" }, text=True)
since = soup.findAll("th", { "class" : "gsc_rsb_sth" }, text = True)
#print career record
#print "------------------------------------------"
print "Citations: Career = %s and %s = %s" %(str(career[0].get_text()), str(since[1].get_text()), str(career[1].get_text()))
print "H-index: Career = %s and %s = %s" %(str(career[2].get_text()), str(since[1].get_text()), str(career[3].get_text()))
print "!10 Index: Career = %s and %s = %s" %(str(career[4].get_text()), str(since[1].get_text()), str(career[5].get_text()))
#print "------------------------------------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment