From 753e41d819030a62418705fc4484d9303e3e1a00 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 3 Nov 2018 18:10:21 +0100 Subject: scripts to fetch papers from main s2 api --- s2.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 's2.py') diff --git a/s2.py b/s2.py index 5ebe507b..c9de75e6 100644 --- a/s2.py +++ b/s2.py @@ -115,6 +115,7 @@ class SemanticScholarAPI(object): AUTHOR_ENDPOINT = "{}/{}".format(BASE_URL, "author") PAPER_ENDPOINT = "{}/{}".format(BASE_URL, "paper") SEARCH_ENDPOINT = "https://www.semanticscholar.org/api/1/search" + RAW_PAPER_ENDPOINT = "https://www.semanticscholar.org/api/1/paper" @staticmethod def paper(paper_id, **kwargs): @@ -132,6 +133,12 @@ class SemanticScholarAPI(object): def pdf_url(paper_id): return "http://pdfs.semanticscholar.org/{}/{}.pdf".format(paper_id[:4], paper_id[4:]) + @staticmethod + def raw_paper(paper_id, **kwargs): + url = "{}/{}".format(SemanticScholarAPI.RAW_PAPER_ENDPOINT, paper_id) + resp = requests.get(url, params=kwargs) + return None if resp.status_code != 200 else resp.json() # Paper(**resp.json()) + @staticmethod def search(q): resp = requests.post(SemanticScholarAPI.SEARCH_ENDPOINT, json={ -- cgit v1.2.3-70-g09d2