Skip to content

Adds offset parameter for paging, fixes issue #43 #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions scholar.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ class SearchScholarQuery(ScholarQuery):
+ '&as_oq=%(words_some)s' \
+ '&as_eq=%(words_none)s' \
+ '&as_occt=%(scope)s' \
+ '&start=%(start)s' \
+ '&as_sauthors=%(authors)s' \
+ '&as_publication=%(pub)s' \
+ '&as_ylo=%(ylo)s' \
Expand All @@ -730,6 +731,7 @@ def __init__(self):
self.words = None # The default search behavior
self.words_some = None # At least one of those words
self.words_none = None # None of these words
self.start = None
self.phrase = None
self.scope_title = False # If True, search in title only
self.author = None
Expand Down Expand Up @@ -769,6 +771,13 @@ def set_pub(self, pub):
"""Sets the publication in which the result must be found."""
self.pub = pub

def set_start(self, start):
"""
Sets result offset for paging. Offset is in number of results, so
should be a multiple of num/count.
"""
self.start = ScholarUtils.ensure_int(start)

def set_timeframe(self, start=None, end=None):
"""
Sets timeframe (in years as integer) in which result must have
Expand Down Expand Up @@ -810,6 +819,7 @@ def get_url(self):
'words_some': words_some or '',
'words_none': words_none or '',
'phrase': self.phrase or '',
'start': self.start or '',
'scope': 'title' if self.scope_title else 'any',
'authors': self.author or '',
'pub': self.pub or '',
Expand Down