-
-
Save anonymous/11505106 to your computer and use it in GitHub Desktop.
extract channel info from http://sky.fm and make a json blob
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
from pprint import pprint | |
import urllib | |
serviceurl = 'http://www.sky.fm' | |
data = urllib.urlopen(serviceurl) | |
page = data.readlines() | |
findme = "NS('AudioAddict.API.Config').channels" | |
json_list = [] | |
for line in page: | |
if findme in line: | |
# We don't want the preamble, only the json blob, so find where in the | |
# line the blob begins '[', then extract and strip whitespace. The | |
# result will have a semi-colon at the end, so remove that, then load | |
# the blob as a json (list) object. | |
pos = line.find('[') | |
json_blob = line[pos:].strip() | |
json_blob = json_blob[:-1] | |
json_list = json.loads(json_blob) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment