Print Google Scholar citations to a text file

Do you frequently check Google Scholar citations of a public profile? Here is a python script to print the total number of citation in a text file.

#/usr/bin/python

import urllib2
import re

def FetchCitations(result):
        cit = re.search('gsc_rsb_std">([0-9]+)', result)
        print cit.group(1)
        try:
                with open('/tmp/citations.txt','w') as f:
                        f.write(cit.group(1))
        except IOError as err:
                print('File error: '+str(err))
        f.close()

url = "https://scholar.google.com/citations?user=profile_id_here"
try:
        result = urllib2.urlopen(url)
        result = result.read()
        FetchCitations(result)
except urllib2.URLError, e:
        handleError(e)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License