Saving a json file to computer python
You can do it just as you would without requests
. Your code might look something like,
import json
import requests
solditems = requests.get('https://github.com/timeline.json') # (your url)
data = solditems.json()
with open('data.json', 'w') as f:
json.dump(data, f)
This is also very easy with the standard library's new pathlib
library. Do note that this code is purely "writing the bytes of an HTTP response to a file". It's fast, but it does no validation that the bytes you're writing are valid JSON.
import requests
import pathlib
solditems = requests.get('https://github.com/timeline.json') # (your url)
pathlib.Path('data.json').write_bytes(solditems.content)