Skip to content

Commit

Permalink
Merge pull request #242 from scholarly-python-package/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
programize-admin committed Jan 21, 2021
2 parents d6c95a7 + b14073f commit bc0ab17
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
25 changes: 18 additions & 7 deletions scholarly/_scholarly.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def set_timeout(self, timeout: int):
def search_pubs(self,
query: str, patents: bool = True,
citations: bool = True, year_low: int = None,
year_high: int = None, sortby_date: str = None)->_SearchScholarIterator:
year_high: int = None, sort_by: str = "relevance",
include_last_year: str = "abstracts")->_SearchScholarIterator:
"""Searches by query and returns a generator of Publication objects
:param query: terms to be searched
Expand All @@ -72,8 +73,10 @@ def search_pubs(self,
:type year_low: int, optional
:param year_high: maximum year of publication, defaults to None
:type year_high: int, optional
:param sortby_date: 'abstracts' for abstracts, 'everything' for all results
:type sortyby_date: string, optional
:param sort_by: 'relevance' or 'date', defaults to 'relevance'
:type sort_by: string, optional
:param include_last_year: 'abstracts' or 'everything', defaults to 'abstracts' and only applies if 'sort_by' is 'date'
:type include_last_year: string, optional
:returns: Generator of Publication objects
:rtype: Iterator[:class:`Publication`]
Expand Down Expand Up @@ -124,10 +127,18 @@ def search_pubs(self,
patents = '&as_sdt={0},33'.format(1 - int(patents))
sortby = ''

if sortby_date == 'abstract':
sortby = '&scisbd=1'
elif sortby_date == 'everything':
sortby = '&scisbd=2'
if sort_by == "date":
if include_last_year == "abstracts":
sortby = '&scisbd=1'
elif include_last_year == "everything":
sortby = '&scisbd=2'
else:
print("Invalid option for 'include_last_year', available options: 'everything', 'abstracts'")
return
elif sort_by != "relevance":
print("Invalid option for 'sort_by', available options: 'relevance', 'date'")
return

# improve str below
url = url + yr_lo + yr_hi + citations + patents + sortby
return self.__nav.search_publications(url)
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='scholarly',
version='1.0.4',
version='1.0.5',
author='Steven A. Cholewiak, Panos Ipeirotis, Victor Silva',
author_email='steven@cholewiak.com, panos@stern.nyu.edu, vsilva@ualberta.ca',
description='Simple access to Google Scholar authors and citations',
Expand Down Expand Up @@ -36,6 +36,7 @@
'python-dotenv',
'free-proxy',
'sphinx_rtd_theme',
'typing_extensions'
],
test_suite="test_module.py"
)

0 comments on commit bc0ab17

Please sign in to comment.