summaryrefslogtreecommitdiff
path: root/s2.py
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-11-03 18:10:21 +0100
committerJules Laplace <julescarbon@gmail.com>2018-11-03 18:10:21 +0100
commit753e41d819030a62418705fc4484d9303e3e1a00 (patch)
tree40a13336278e330de882de3cca90134286d8c952 /s2.py
parentaa0470a3076f5ac65a0311c76e58254547f3eae0 (diff)
scripts to fetch papers from main s2 api
Diffstat (limited to 's2.py')
-rw-r--r--s2.py7
1 files changed, 7 insertions, 0 deletions
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):
@@ -133,6 +134,12 @@ class SemanticScholarAPI(object):
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={
'authors': [],