Skip to content

Commit

Permalink
Cookie support from Matej, with minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ckreibich committed Nov 30, 2013
1 parent c015232 commit a2ac9e0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scholar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# ChangeLog
# ---------
#
# 1.6: Cookie support, from Matej Smid (https://github.com/palmstrom).
#
# 1.5: A few changes:
#
# - Tweak suggested by Tobias Isenberg: use unicode during CSV
Expand Down Expand Up @@ -297,16 +299,14 @@ def __init__(self, author='', scholar_url=None, count=0):
if self.count != 0:
self.scholar_url += '&num=%d' % self.count

self.cj = CookieJar()
self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
self.cjar = CookieJar()
self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cjar))

def query(self, search):
"""
This method initiates a query with subsequent parsing of the
response.
"""

# clears old results
self.clear_articles()
url = self.scholar_url % {'query': urllib.quote(search.encode('utf-8')), 'author': urllib.quote(self.author)}
req = urllib2.Request(url=url,
Expand All @@ -325,8 +325,8 @@ def parse(self, html):
def add_article(self, art):
self.articles.append(art)

# clears results
def clear_articles(self):
"""Clears any existing articles stored from previous queries."""
self.articles = []


Expand Down

0 comments on commit a2ac9e0

Please sign in to comment.