H-Index with Google Scholar

Discussion in 'Python' started by Gonsolo, Feb 25, 2009.

  1. Gonsolo

    Gonsolo Guest

    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
     
    Gonsolo, Feb 25, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Thompson

    FAQ - references to Google/Google Groups

    Andrew Thompson, Jun 20, 2005, in forum: Java
    Replies:
    0
    Views:
    629
    Andrew Thompson
    Jun 20, 2005
  2. Tomasz Chmielewski

    sorting index-15, index-9, index-110 "the human way"?

    Tomasz Chmielewski, Mar 4, 2008, in forum: Perl Misc
    Replies:
    4
    Views:
    298
    Tomasz Chmielewski
    Mar 4, 2008
  3. Replies:
    1
    Views:
    340
    David RF
    May 23, 2012
  4. রà§à¦¦à§à¦° বà§à¦¯à¦¾à¦£à¦¾à¦°à§à¦œà§€

    get google scholar using python

    রà§à¦¦à§à¦° বà§à¦¯à¦¾à¦£à¦¾à¦°à§à¦œà§€, Oct 1, 2012, in forum: Python
    Replies:
    4
    Views:
    447
    Jerry Hill
    Oct 1, 2012
  5. রà§à¦¦à§à¦° বà§à¦¯à¦¾à¦£à¦¾à¦°à§à¦œà§€

    tidy to convert google scholar page in xml

    রà§à¦¦à§à¦° বà§à¦¯à¦¾à¦£à¦¾à¦°à§à¦œà§€, Oct 8, 2012, in forum: Python
    Replies:
    1
    Views:
    235
    Dave Angel
    Oct 8, 2012
Loading...

Share This Page