gnunetbib

Bibliography (BibTeX, based on AnonBib)
Log | Files | Refs | README | LICENSE

commit b7611dda9092ff08bdd741837d0fb8625126f109
parent a7ac9cd5545a11d7df3da0517a07557f0e7d7f21
Author: Nick Mathewson <nickm@torproject.org>
Date:   Wed, 30 Jul 2008 18:39:02 +0000

Do not actually build a URL opener for ranks until we know we have a cacche miss.  Under some circumstances, building the opener hits the network.

svn:r291

Diffstat:
Mrank.py | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/rank.py b/rank.py @@ -56,9 +56,6 @@ def getCite(title, cache=True, update=True, save=True): title = re.sub("[^'a-zA-Z0-9\. \-\/:]", "", title) title = re.sub("'\/", " ", title) - # Make a custom user agent (so that we are not filtered by Google)! - opener = build_opener() - opener.addheaders = [('User-agent', 'Anon.Bib.0.1')] # We rely on google scholar to return the article with this exact title gurl = "http://scholar.google.com/scholar?as_epq=%s&as_occt=title" @@ -70,6 +67,11 @@ def getCite(title, cache=True, update=True, save=True): page = file(join(cache_folder(), md5h(url)),'r').read() elif update: print "Downloading rank for %r."%title + + # Make a custom user agent (so that we are not filtered by Google)! + opener = build_opener() + opener.addheaders = [('User-agent', 'Anon.Bib.0.1')] + page = opener.open(url).read() if save: file(join(cache_folder(), md5h(url)),'w').write(page) else: