wrongmove/crawler/2_dump_detail.py

26 lines
563 B
Python
Raw Normal View History

import pathlib
import json
from rec.query import detail_query
folder = pathlib.Path('data/rs/')
listings = folder.glob('*/listing.json')
for listing_path in listings:
with open(listing_path) as f:
listing = json.load(f)
identifier = listing['identifier']
try:
d = detail_query(identifier)
except:
print('Failed at: ', identifier)
raise
print(identifier)
detail_path = pathlib.Path(f'data/rs/{identifier}/detail.json')
with open(detail_path, 'w') as f:
json.dump(d, f)