]> code.communitydata.science - social-media-chapter.git/blob - code/data_collection/00_get_search_results.py
initial import of material for public archive into git
[social-media-chapter.git] / code / data_collection / 00_get_search_results.py
1 import argparse
2 from request_functions import *
3
4 '''
5 This script takes in a search query and an output file. It queries the scopus API to find all papers that match the search query, and saves them to the output file.
6
7 Unlike some of the other scripts in this directory, it does not try to determine the state - if you restart the script, it will start over and blow away whatever you had saved before.
8 '''
9
10 years = range(2004, 2017)
11
12 def main():
13
14     parser = argparse.ArgumentParser(description='Output JSON of all articles matching search query')
15     parser.add_argument('-q', help='Search query', required=True)
16     parser.add_argument('-o', help='Where to append JSON results')
17     args = parser.parse_args()
18
19     with open(args.o, 'w') as out_file:
20         for year in years:
21             get_search_results(args.q, out_file, year=year)
22
23 if __name__ == '__main__':
24     main()

Community Data Science Collective || Want to submit a patch?