H-Index with Google Scholar

G

Gonsolo

I wrote a small script to compute the H-Index of an author.
It is modeled after activestate's google search:
http://code.activestate.com/recipes/523047/

Example use:
hindex i daubechies
Result:
49

The script:

#!/usr/bin/python

import httplib, urllib, re, sys
from BeautifulSoup import BeautifulSoup

terms = sys.argv[1:]
limit = 100
params = urllib.urlencode( { 'q': "+".join( terms ), 'num': limit } )
headers = {'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows
NT)'}
url = '/scholar'+"?"+params
conn = httplib.HTTPConnection( 'scholar.google.com' )
conn.request( "GET", url, {}, headers )

resp = conn.getresponse()
cites = []
if resp.status == 200:
html = resp.read()
html = html.decode( 'ascii', 'ignore' )
soup = BeautifulSoup( html )
for record in soup( 'p', { 'class': 'g' } ):
match = re.search("Cited by ([^<]*)", str(record))
if match != None:
cite = int( match.group( 1 ) )
cites.append( cite )
else:
print 'Error: '
print resp.status, resp.reason

cites.sort()
cites.reverse()

h = 0
for cite in cites:
if cite > h:
h += 1
print h
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top