Skip to content
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

Add the following query options: "review articles only", "search on a specific language" #512

Closed
wants to merge 2 commits into from
Closed
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
15 changes: 12 additions & 3 deletions scholarly/_scholarly.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ def set_timeout(self, timeout: int):
self.__nav.set_timeout(timeout)

def search_pubs(self,
query: str, patents: bool = True,
citations: bool = True, year_low: int = None,
query: str, patents: bool = True,
review_only: bool = False, language: str = "en",
citations: bool = True, year_low: int = None,
year_high: int = None, sort_by: str = "relevance",
include_last_year: str = "abstracts",
start_index: int = 0)->_SearchScholarIterator:
Expand All @@ -100,6 +101,10 @@ def search_pubs(self,
:type query: str
:param patents: Whether or not to include patents, defaults to True
:type patents: bool, optional
:param review_only: whether or not to search only review articles
:type review_only: bool, optional
:param language: search for content in a specific language
:type language: string, optional
:param citations: Whether or not to include citations, defaults to True
:type citations: bool, optional
:param year_low: minimum year of publication, defaults to None
Expand Down Expand Up @@ -155,6 +160,7 @@ def search_pubs(self,

"""
url = self._construct_url(_PUBSEARCH.format(requests.utils.quote(query)), patents=patents,
review_only=review_only, language=language,
citations=citations, year_low=year_low, year_high=year_high,
sort_by=sort_by, include_last_year=include_last_year, start_index=start_index)
return self.__nav.search_publications(url)
Expand Down Expand Up @@ -569,6 +575,7 @@ def download_mandates_csv(self, filename: str, overwrite: bool = False,

# TODO: Make it a public method in v1.6
def _construct_url(self, baseurl: str, patents: bool = True,
review_only: bool = False, language: str = "en",
citations: bool = True, year_low: int = None,
year_high: int = None, sort_by: str = "relevance",
include_last_year: str = "abstracts",
Expand All @@ -580,6 +587,8 @@ def _construct_url(self, baseurl: str, patents: bool = True,
yr_hi = '&as_yhi={0}'.format(year_high) if year_high is not None else ''
citations = '&as_vis={0}'.format(1 - int(citations))
patents = '&as_sdt={0},33'.format(1 - int(patents))
review_only = '&as_rr={}'.format(int(review_only))
language = '&lang_{0}'.format(language) if language is not None else''
sortby = ''
start = '&start={0}'.format(start_index) if start_index > 0 else ''

Expand All @@ -596,7 +605,7 @@ def _construct_url(self, baseurl: str, patents: bool = True,
return

# improve str below
return url + yr_lo + yr_hi + citations + patents + sortby + start
return url + yr_lo + yr_hi + citations + patents + review_only + language + sortby + start

def get_journal_categories(self):
"""
Expand Down
Loading