Skip to content

Commit acbb1ef

Browse files
Merge pull request #436 from scholarly-python-package/develop
Release v1.7.2
2 parents 816b4e3 + 1952c62 commit acbb1ef

4 files changed

Lines changed: 20 additions & 8 deletions

File tree

scholarly/_proxy_generator.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,17 @@ def _use_proxy(self, http: str, https: str = None) -> bool:
185185
https = http
186186

187187
proxies = {'http': http, 'https': https}
188-
self._proxy_works = self._check_proxy(proxies)
188+
if self.proxy_mode == ProxyMode.SCRAPERAPI:
189+
r = requests.get("http://api.scraperapi.com/account", params={'api_key': self._API_KEY}).json()
190+
if "error" in r:
191+
self.logger.warning(r["error"])
192+
self._proxy_works = False
193+
else:
194+
self._proxy_works = r["requestCount"] < int(r["requestLimit"])
195+
self.logger.info("Successful ScraperAPI requests %d / %d",
196+
r["requestCount"], r["requestLimit"])
197+
else:
198+
self._proxy_works = self._check_proxy(proxies)
189199

190200
if self._proxy_works:
191201
self._session.proxies = proxies
@@ -562,6 +572,9 @@ def ScraperAPI(self, API_KEY, country_code=None, premium=False, render=False):
562572
self.logger.warning(r["error"])
563573
return False
564574

575+
self._API_KEY = API_KEY
576+
self.proxy_mode = ProxyMode.SCRAPERAPI
577+
565578
r["requestLimit"] = int(r["requestLimit"])
566579
self.logger.info("Successful ScraperAPI requests %d / %d",
567580
r["requestCount"], r["requestLimit"])
@@ -586,7 +599,6 @@ def ScraperAPI(self, API_KEY, country_code=None, premium=False, render=False):
586599
proxy_works = self._use_proxy(http=f'{prefix}:{API_KEY}@proxy-server.scraperapi.com:8001')
587600
if proxy_works:
588601
self.logger.info("ScraperAPI proxy setup successfully")
589-
self.proxy_mode = ProxyMode.SCRAPERAPI
590602
self._session.verify = False
591603
return proxy_works
592604

scholarly/_scholarly.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
_AUTHSEARCH = '/citations?hl=en&view_op=search_authors&mauthors={0}'
1616
_KEYWORDSEARCH = '/citations?hl=en&view_op=search_authors&mauthors=label:{0}'
1717
_KEYWORDSEARCHBASE = '/citations?hl=en&view_op=search_authors&mauthors={}'
18-
_PUBSEARCH = '/scholar?hl=en&num=20&q={0}'
19-
_CITEDBYSEARCH = '/scholar?hl=en&num=20&cites={0}'
18+
_PUBSEARCH = '/scholar?hl=en&q={0}'
19+
_CITEDBYSEARCH = '/scholar?hl=en&cites={0}'
2020
_ORGSEARCH = "/citations?view_op=view_org&hl=en&org={0}"
2121
_MANDATES_URL = "https://scholar.google.com/citations?view_op=mandates_leaderboard_csv&hl=en"
2222

scholarly/publication_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
_SCHOLARPUBRE = r'cites=([\d,]*)'
99
_CITATIONPUB = '/citations?hl=en&view_op=view_citation&citation_for_view={0}'
10-
_SCHOLARPUB = '/scholar?hl=en&num=20&oi=bibs&cites={0}'
10+
_SCHOLARPUB = '/scholar?hl=en&oi=bibs&cites={0}'
1111
_CITATIONPUBRE = r'citation_for_view=([\w-]*:[\w-]*)'
12-
_BIBCITE = '/scholar?hl=en&num=20&q=info:{0}:scholar.google.com/\
12+
_BIBCITE = '/scholar?hl=en&q=info:{0}:scholar.google.com/\
1313
&output=cite&scirp={1}&hl=en'
14-
_CITEDBYLINK = '/scholar?hl=en&num=20&cites={0}'
14+
_CITEDBYLINK = '/scholar?hl=en&cites={0}'
1515
_MANDATES_URL = '/citations?view_op=view_mandate&hl=en&citation_for_view={0}'
1616

1717
_BIB_MAPPING = {

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.7.1',
8+
version='1.7.2',
99
author='Steven A. Cholewiak, Panos Ipeirotis, Victor Silva, Arun Kannawadi',
1010
author_email='steven@cholewiak.com, panos@stern.nyu.edu, vsilva@ualberta.ca, arunkannawadi@astro.princeton.edu',
1111
description='Simple access to Google Scholar authors and citations',

0 commit comments

Comments
 (0)