summaryrefslogtreecommitdiff
path: root/scraper/s2-papers.py
diff options
context:
space:
mode:
authoradamhrv <adam@ahprojects.com>2018-12-15 19:57:49 +0100
committeradamhrv <adam@ahprojects.com>2018-12-15 19:57:49 +0100
commit82b2c0b5d6d7baccbe4d574d96e18fe2078047d7 (patch)
treea8784b7ec2bc5a0451c252f66a6b786f3a2504f5 /scraper/s2-papers.py
parent8e978af21c2b29f678a09701afb3ec7d65d0a6ab (diff)
parentc5b02ffab8d388e8a2925e51736b902a48a95e71 (diff)
Merge branch 'master' of github.com:adamhrv/megapixels_dev
Diffstat (limited to 'scraper/s2-papers.py')
-rw-r--r--scraper/s2-papers.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/scraper/s2-papers.py b/scraper/s2-papers.py
new file mode 100644
index 00000000..bf77a734
--- /dev/null
+++ b/scraper/s2-papers.py
@@ -0,0 +1,46 @@
+import os
+import sys
+import csv
+import subprocess
+import time
+import random
+import re
+import simplejson as json
+import click
+from s2 import SemanticScholarAPI
+from util import *
+
+'''
+s2 search API format:
+results
+matchedAuthors
+matchedPresentations
+query
+querySuggestions
+results
+stats
+totalPages
+totalResults
+'''
+
+s2 = SemanticScholarAPI()
+
+@click.command()
+@click.option('--index', '-n', default=0, help='Index of CSV (query,)')
+@click.option('--depth', '-d', default=1, help='Depth to recurse (not implemented).')
+def fetch_papers(index, depth):
+ keys, lines = read_citation_list(index)
+ for line in lines:
+ label = line[0]
+ title = re.sub(r'[^-0-9a-zA-Z ]+', '', line[1])
+ entry_fn = './datasets/s2/entries/{}.json'.format(title)
+ if not os.path.exists(entry_fn):
+ print('not found: {}'.format(entry_fn))
+ continue
+ result = read_json(entry_fn)
+ paper_id = result['id']
+ paper = fetch_paper(paper_id)
+ # get all of the paper's citations
+
+if __name__ == '__main__':
+ fetch_papers()