From 6fa2b98685fafc63385bc5618c043c120933a811 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 6 Nov 2018 16:14:36 +0100 Subject: raw paper scrapes --- s2.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 's2.py') diff --git a/s2.py b/s2.py index b6b3caef..8add3205 100644 --- a/s2.py +++ b/s2.py @@ -137,6 +137,22 @@ class SemanticScholarAPI(object): f.write(chunk) 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) -- cgit v1.2.3-70-g09d2