Skip to content

Commit 58ef0f6

Browse files
committed
Enforce English language in all URLs
The logic assumed that the page is in English, but freeproxies can fetch the page from different countries in their local language. This was causing an error mentioned in #413.
1 parent a47fdfd commit 58ef0f6

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

scholarly/_scholarly.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
_PUBSEARCH = '/scholar?hl=en&q={0}'
1919
_CITEDBYSEARCH = '/scholar?hl=en&cites={0}'
2020
_ORGSEARCH = "/citations?view_op=view_org&hl=en&org={0}"
21-
_MANDATES_URL = "https://scholar.google.com/citations?view_op=mandates_leaderboard_csv"
21+
_MANDATES_URL = "https://scholar.google.com/citations?view_op=mandates_leaderboard_csv&hl=en"
2222

2323

2424
class _Scholarly:
@@ -485,7 +485,7 @@ def download_mandates_csv(self, filename: str, overwrite: bool = False,
485485
"setting overwrite=True")
486486
text = self.__nav._get_page(_MANDATES_URL, premium=False)
487487
if include_links:
488-
soup = self.__nav._get_soup("/citations?view_op=mandates_leaderboard")
488+
soup = self.__nav._get_soup("/citations?hl=en&view_op=mandates_leaderboard")
489489
text = text.replace("Funder,", "Funder,Policy,Cached,", 1)
490490
for agency in soup.find_all("td", class_="gsc_mlt_t"):
491491
cached = agency.find("span", class_="gs_a").a["href"]

scholarly/publication_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
_CITATIONPUB = '/citations?hl=en&view_op=view_citation&citation_for_view={0}'
1010
_SCHOLARPUB = '/scholar?hl=en&oi=bibs&cites={0}'
1111
_CITATIONPUBRE = r'citation_for_view=([\w-]*:[\w-]*)'
12-
_BIBCITE = '/scholar?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?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 = {

0 commit comments

Comments
 (0)