diff --git a/scholarly/publication_parser.py b/scholarly/publication_parser.py index 5d7bf37..5d7e728 100644 --- a/scholarly/publication_parser.py +++ b/scholarly/publication_parser.py @@ -58,7 +58,7 @@ def _load_url(self, url: str): # this is temporary until setup json file self._soup = self._nav._get_soup(url) self._pos = 0 - self._rows = self._soup.find_all('div', class_='gs_r gs_or gs_scl') + self._soup.find_all('div', class_='gsc_mpat_ttl') + self._rows = self._soup.find_all('div', class_='gs_r gs_or gs_scl') + self._soup.find_all('div', class_='gs_r gs_or gs_scl gs_fmar') + self._soup.find_all('div', class_='gsc_mpat_ttl') def _get_total_results(self): if self._soup.find("div", class_="gs_pda"): @@ -70,7 +70,7 @@ def _get_total_results(self): match = re.match(pattern=r'(^|\s*About)\s*([0-9,\.\s’]+)', string=x.text) if match: return int(re.sub(pattern=r'[,\.\s’]',repl='', string=match.group(2))) - return 0 + return len(self._rows) # Iterator protocol diff --git a/test_module.py b/test_module.py index b2a3ac5..bcd93e4 100644 --- a/test_module.py +++ b/test_module.py @@ -718,6 +718,23 @@ def test_search_pubs(self): titles = [p['bib']['title'] for p in pubs] self.assertIn('Visual perception of the physical stability of asymmetric three-dimensional objects', titles) + def test_search_pubs_single_pub(self): + """ + As of Jun 24, 2024 there are is only one pub that fits the search term: + [Perception of physical stability and center of mass of 3D objects]. + + Check that it returns a proper result and the total results for that search term is equal to 1. + """ + pub = scholarly.search_single_pub("Perception of physical stability and center of mass of 3D objects") + pubs = list(scholarly.search_pubs("Perception of physical stability and center of mass of 3D objects")) + # Check that the first entry in pubs is the same as pub. + # Checking for quality holds for non-dict entries only. + for key in {'author_id', 'pub_url', 'num_citations'}: + self.assertEqual(pub[key], pubs[0][key]) + for key in {'title', 'pub_year', 'venue'}: + self.assertEqual(pub['bib'][key], pubs[0]['bib'][key]) + self.assertEqual(len(pubs), 1) + def test_search_pubs_total_results(self): """ As of September 16, 2021 there are 32 pubs that fit the search term: