def add_scrape_data(symbol, scrape_data, complete):
"""Add data regarding scrape to scrape log."""
if complete:
complete_key = 'complete'
else:
complete_key = 'incomplete'
data_log = pickle.load(open(settings.SCRAPE_LOG_FILE_PATH, "rb"))
try:
data_log[symbol]
data_log[symbol][complete_key] = scrape_data
except KeyError:
data_log[symbol] = {}
data_log[symbol]['complete'] = None
data_log[symbol]['incomplete'] = None
data_log[symbol][complete_key] = scrape_data
pickle.dump(data_log, open(settings.SCRAPE_LOG_FILE_PATH, "wb"))
评论列表
文章目录