Skip to content

Commit 00fbcef

Browse files
Merge pull request #266 from scholarly-python-package/develop
Develop
2 parents 8a3f431 + ecff82b commit 00fbcef

File tree

8 files changed

+553
-505
lines changed

8 files changed

+553
-505
lines changed

README.md

Lines changed: 2 additions & 495 deletions
Large diffs are not rendered by default.

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Welcome to scholarly's documentation!
77
========================================
88

99
.. toctree::
10-
:maxdepth: 2
10+
:maxdepth: 5
1111
:caption: Index
1212

1313
quickstart

docs/quickstart.rst

Lines changed: 522 additions & 6 deletions
Large diffs are not rendered by default.

scholarly/_scholarly.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,14 @@ def pprint(self, object: Author or Publication)->None:
407407
print(pprint.pformat(to_print))
408408

409409
def search_org(self, name: str, fromauthor: bool = False) -> list:
410-
"""Search by organization name and return a list of possible disambiguations
410+
"""
411+
Search by organization name and return a list of possible disambiguations
412+
411413
:Example::
412414
.. testcode::
413415
search_query = scholarly.search_org('ucla')
414416
print(search_query)
417+
415418
:Output::
416419
.. testoutput::
417420
[{'Organization': 'University of California, Los Angeles',

scholarly/author_parser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ def _fill_basics(self, soup, author):
8585
if "avatar_scholar" in picture:
8686
picture = _HOST.format(picture)
8787
author['url_picture'] = picture
88-
88+
index = soup.find_all('td', class_='gsc_rsb_std')
89+
if index:
90+
author['citedby'] = int(index[0].text)
91+
8992
def _fill_indices(self, soup, author):
9093
index = soup.find_all('td', class_='gsc_rsb_std')
9194
if index:

scholarly/publication_parser.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def __init__(self, nav, url: str):
5151
self._url = url
5252
self._nav = nav
5353
self._load_url(url)
54+
self.total_results = self._get_total_results()
5455
self.pub_parser = PublicationParser(self._nav)
5556

5657
def _load_url(self, url: str):
@@ -59,6 +60,14 @@ def _load_url(self, url: str):
5960
self._pos = 0
6061
self._rows = self._soup.find_all('div', class_='gs_r gs_or gs_scl')
6162

63+
def _get_total_results(self):
64+
for x in self._soup.find_all('div', class_='gs_ab_mdw'):
65+
# Decimal separator is set by Google independent of language setting
66+
match = re.match(pattern=r'(^|\s*About)\s*([0-9,\.]+)', string=x.text)
67+
if match:
68+
return int(re.sub(pattern=r'[,\.]',repl='', string=match.group(2)))
69+
return None
70+
6271
# Iterator protocol
6372

6473
def __iter__(self):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name='scholarly',
8-
version='1.0.7',
8+
version='1.1.0',
99
author='Steven A. Cholewiak, Panos Ipeirotis, Victor Silva',
1010
author_email='steven@cholewiak.com, panos@stern.nyu.edu, vsilva@ualberta.ca',
1111
description='Simple access to Google Scholar authors and citations',

test_module.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,16 @@ def test_search_pubs(self):
180180

181181
self.assertIn('Visual perception of the physical stability of asymmetric three-dimensional objects', pubs)
182182

183+
def test_search_pubs_total_results(self):
184+
"""
185+
As of February 4, 2021 there are 32 pubs that fit the search term:
186+
["naive physics" stability "3d shape"].
187+
188+
Check that the total results for that search term equals 32.
189+
"""
190+
pubs = scholarly.search_pubs('"naive physics" stability "3d shape"')
191+
self.assertGreaterEqual(pubs.total_results, 32)
192+
183193
def test_search_pubs_filling_publication_contents(self):
184194
'''
185195
This process checks the process of filling a publication that is derived

0 commit comments

Comments
 (0)