Commit 1341782c authored by Евгений Третьяков's avatar Евгений Третьяков
Browse files

Add new file

parent 79ff7d5d
import concurrent.futures
import json
import requests
def load_recids_list(file_path):
with open(file_path, "r", encoding="utf-8") as file:
content = [line for line in file.read().split("\n") if line]
recids_list = [line.split()[0] for line in content]
return recids_list
def download_record_json(recid):
json_url = f"https://labs.inspirehep.net/api/literature/{recid}"
response = requests.get(json_url)
file_path = f"output/records_jsons/{recid}.json"
with open(file_path, "w", encoding="utf-8") as file:
file.write(json.dumps(response.json()))
def download_record_jsons(file_path):
recids_list = load_recids_list(file_path)
with concurrent.futures.ProcessPoolExecutor(max_workers=10) as executor:
for recid in recids_list:
executor.submit(download_record_json, recid)
if __name__ == '__main__':
download_record_jsons("source/2019-10-10-13-23-30.txt")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment