Crawl and Store HTML
import hashlib
import requests
import os
def get_html(url):
fname = './{}.html'.format(hashlib.sha256(url.encode('utf-8')).hexdigest())
if not os.path.exists(fname):
resp = requests.get(url)
assert resp.status_code == 200
with open(fname, 'w') as f:
f.write(resp.text)
return resp.text
else:
with open(fname) as f:
return f.read()
INFO