summaryrefslogtreecommitdiff
path: root/s2.py
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-11-06 16:14:36 +0100
committerJules Laplace <julescarbon@gmail.com>2018-11-06 16:14:36 +0100
commit6fa2b98685fafc63385bc5618c043c120933a811 (patch)
treea85c939a836b9eeb742e7dd7c3c38c1bfdf1f2ab /s2.py
parente6a19cb5c9db39f00eb83cf0ae48edc85878e08e (diff)
raw paper scrapes
Diffstat (limited to 's2.py')
-rw-r--r--s2.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/s2.py b/s2.py
index b6b3caef..8add3205 100644
--- a/s2.py
+++ b/s2.py
@@ -138,6 +138,22 @@ class SemanticScholarAPI(object):
return size
@staticmethod
+ def fetch_doi(url, fn, **kwargs):
+ try:
+ resp = requests.get(url, params=kwargs, headers=SemanticScholarAPI.headers, verify=False)
+ if resp.status_code != 200:
+ return None
+ except:
+ return None
+ size = 0
+ with open(fn, 'wb') as f:
+ for chunk in resp.iter_content(chunk_size=1024):
+ if chunk:
+ size += len(chunk)
+ f.write(chunk)
+ return size, response.url
+
+ @staticmethod
def paper(paper_id, **kwargs):
url = "{}/{}".format(SemanticScholarAPI.PAPER_ENDPOINT, paper_id)
resp = requests.get(url, params=kwargs, headers=SemanticScholarAPI.headers)