diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-11-06 16:14:36 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-11-06 16:14:36 +0100 |
| commit | 6fa2b98685fafc63385bc5618c043c120933a811 (patch) | |
| tree | a85c939a836b9eeb742e7dd7c3c38c1bfdf1f2ab /s2.py | |
| parent | e6a19cb5c9db39f00eb83cf0ae48edc85878e08e (diff) | |
raw paper scrapes
Diffstat (limited to 's2.py')
| -rw-r--r-- | s2.py | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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) |
