Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Python script to get JSON data from an online source. Seems to work only with Python 2.
import urllib2
import json
opener = urllib2.build_opener()
# An object to collect the results
result = {'episodes':[]}
# Iterate from 1 to 31
for i in range(1, 32):
# Get the data
req = urllib2.Request("" + str(i))
f =
res =
# Convert it to JSON
obj = json.loads(res)
# Append the data to the result
# Write it to a file
writeFile = open('episodes.json', 'wb')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment