Skip to content

Commit 7f075cf

Browse files
jjshootsarunkannawadi
authored andcommitted
Increase number of citations returned by citedby
1 parent 04cd545 commit 7f075cf

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

scholarly/_scholarly.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import copy
66
import csv
77
import pprint
8+
import datetime
9+
import itertools
10+
import warnings
811
from typing import Dict, List
912
from ._navigator import Navigator
1013
from ._proxy_generator import ProxyGenerator
@@ -257,13 +260,29 @@ def citedby(self, object: Publication)->_SearchScholarIterator:
257260
:param object: The Publication object for the bibtex exportation
258261
:type object: Publication
259262
"""
260-
if object['container_type'] == "Publication":
261-
publication_parser = PublicationParser(self.__nav)
262-
return publication_parser.citedby(object)
263-
else:
263+
264+
if object['container_type'] != "Publication":
264265
self.logger.warning("Object not supported for bibtex exportation")
265266
return
266267

268+
if object["bib"]["citedby"] < 999:
269+
return PublicationParser(self.__nav).citedby(object)
270+
else:
271+
try:
272+
year_low = int(object["bib"]["pub_year"])
273+
year_end = int(datetime.date.today().year)
274+
except KeyError:
275+
self.logger.warning("Unknown publication year for paper %s, may result in incorrect number of citedby papers.", object["bib"]["title"])
276+
return PublicationParser(self.__nav).citedby(object)
277+
278+
pub_id = int(object["citedby_url"].split("=")[1].split("&")[0])
279+
iter_list = []
280+
while year_low < year_end:
281+
iter_list.append(self.search_citedby(publication_id=pub_id, year_low=year_low, year_high=year_low+1))
282+
year_low += 1
283+
284+
return itertools.chain(*iter_list)
285+
267286
def search_author_id(self, id: str, filled: bool = False, sortby: str = "citedby", publication_limit: int = 0)->Author:
268287
"""Search by author id and return a single Author object
269288
:param sortby: select the order of the citations in the author page. Either by 'citedby' or 'year'. Defaults to 'citedby'.

0 commit comments

Comments
 (0)