Created
August 13, 2014 14:23
-
-
Save icholy/dd8d37b6fb0b3c64008a to your computer and use it in GitHub Desktop.
This file contains 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
[ | |
{ | |
"song": "take it or leave it", | |
"artist": "cage the elephant" | |
}, | |
{ | |
"song": "afterlife", | |
"artist": "arcade fire" | |
}, | |
{ | |
"song": "even flow", | |
"artist": "pearl jam" | |
}, | |
{ | |
"song": "stolen dance", | |
"artist": "milky chance" | |
}, | |
{ | |
"song": "take me out", | |
"artist": "franz ferdinand" | |
}, | |
{ | |
"song": "guns + ammunition", | |
"artist": "july talk" | |
}, | |
{ | |
"song": "help, i\\'m alive", | |
"artist": "metric" | |
}, | |
{ | |
"song": "today", | |
"artist": "smashing pumpkins" | |
}, | |
{ | |
"song": "when the night feels my song", | |
"artist": "bedouin soundclash" | |
}, | |
{ | |
"song": "hurricane", | |
"artist": "ms mr" | |
}, | |
{ | |
"song": "the house that heaven built", | |
"artist": "japandroids" | |
}, | |
{ | |
"song": "royals", | |
"artist": "lorde" | |
}, | |
{ | |
"song": "don\\'t look back in anger", | |
"artist": "oasis" | |
}, | |
{ | |
"song": "dangerous", | |
"artist": "big data (feat. joywave)" | |
}, | |
{ | |
"song": "longview", | |
"artist": "green day" | |
}, | |
{ | |
"song": "headphones", | |
"artist": "mounties" | |
}, | |
{ | |
"song": "ways to go", | |
"artist": "grouplove" | |
}, | |
{ | |
"song": "load me up", | |
"artist": "matthew good" | |
}, | |
{ | |
"song": "why\\'d you only callme ....", | |
"artist": "arctic monkeys" | |
}, | |
{ | |
"song": "locked in the trunk of a car", | |
"artist": "tragically hip, the" | |
}, | |
{ | |
"song": "stolen dance", | |
"artist": "milky chance" | |
}, | |
{ | |
"song": "when you were young", | |
"artist": "killers" | |
}, | |
{ | |
"song": "i sat by the ocean", | |
"artist": "queens of the stone age" | |
}, | |
{ | |
"song": "monster hospital", | |
"artist": "metric" | |
}, | |
{ | |
"song": "machinehead", | |
"artist": "bush" | |
}, | |
{ | |
"song": "let\\'s fall in love", | |
"artist": "mother mother" | |
}, | |
{ | |
"song": "bad blood", | |
"artist": "bastille" | |
}, | |
{ | |
"song": "i\\'m only joking", | |
"artist": "kongos" | |
}, | |
{ | |
"song": "by this time tomorrow", | |
"artist": "head of the herd" | |
}, | |
{ | |
"song": "get lucky", | |
"artist": "daft punk" | |
}, | |
{ | |
"song": "you know you\\'re right", | |
"artist": "nirvana" | |
}, | |
{ | |
"song": "come to light", | |
"artist": "arkells" | |
}, | |
{ | |
"song": "flagpole sitta", | |
"artist": "harvey danger" | |
}, | |
{ | |
"song": "pick me up", | |
"artist": "hollerado" | |
}, | |
{ | |
"song": "pumped up kicks", | |
"artist": "foster the people" | |
}, | |
{ | |
"song": "keep the car running", | |
"artist": "arcade fire" | |
}, | |
{ | |
"song": "yellow", | |
"artist": "coldplay" | |
}, | |
{ | |
"song": "at the hundredth meridian", | |
"artist": "the tragically hip" | |
}, | |
{ | |
"song": "little lion man", | |
"artist": "mumford and sons" | |
}, | |
{ | |
"song": "riptide", | |
"artist": "vance joy" | |
}, | |
{ | |
"song": "do i wanna know?", | |
"artist": "arctic monkeys" | |
}, | |
{ | |
"song": "creep", | |
"artist": "radiohead" | |
}, | |
{ | |
"song": "won\\'t turn back", | |
"artist": "our lady peace" | |
}, | |
{ | |
"song": "float on", | |
"artist": "modest mouse" | |
}, | |
{ | |
"song": "little talks", | |
"artist": "of monsters and men" | |
}, | |
{ | |
"song": "dumb", | |
"artist": "nirvana" | |
}, | |
{ | |
"song": "dani california", | |
"artist": "red hot chili peppers" | |
}, | |
{ | |
"song": "trainwreck 1979", | |
"artist": "death from above 1979" | |
}, | |
{ | |
"song": "left hand free", | |
"artist": "alt-j" | |
}, | |
{ | |
"song": "the pretender", | |
"artist": "foo fighters" | |
}, | |
{ | |
"song": "my sweet summer", | |
"artist": "dirty heads" | |
}, | |
{ | |
"song": "take it or leave it", | |
"artist": "cage the elephant" | |
}, | |
{ | |
"song": "what i got", | |
"artist": "sublime" | |
}, | |
{ | |
"song": "afterlife", | |
"artist": "arcade fire" | |
}, | |
{ | |
"song": "i wanna get better", | |
"artist": "bleachers" | |
}, | |
{ | |
"song": "i don\\'t want to be here anymore", | |
"artist": "rise against" | |
}, | |
{ | |
"song": "recovery", | |
"artist": "frank turner" | |
}, | |
{ | |
"song": "habits (stay high)", | |
"artist": "tove lo" | |
}, | |
{ | |
"song": "inside out", | |
"artist": "eve 6" | |
}, | |
{ | |
"song": "the walker", | |
"artist": "fitz and the tantrums" | |
}, | |
{ | |
"song": "last nite", | |
"artist": "strokes" | |
}, | |
{ | |
"song": "bittersweet symphony", | |
"artist": "verve" | |
}, | |
{ | |
"song": "stolen dance", | |
"artist": "milky chance" | |
}, | |
{ | |
"song": "in the end", | |
"artist": "linkin park" | |
}, | |
{ | |
"song": "dammit (growing up)", | |
"artist": "blink-182" | |
}, | |
{ | |
"song": "harder than stone", | |
"artist": "city and colour" | |
}, | |
{ | |
"song": "like a stone", | |
"artist": "audioslave" | |
}, | |
{ | |
"song": "the cave", | |
"artist": "mumford and sons" | |
}, | |
{ | |
"song": "dangerous", | |
"artist": "big data (feat. joywave)" | |
}, | |
{ | |
"song": "better man", | |
"artist": "pearl jam" | |
}, | |
{ | |
"song": "lazaretto", | |
"artist": "jack white" | |
}, | |
{ | |
"song": "pardon me", | |
"artist": "incubus" | |
}, | |
{ | |
"song": "howlin\\' for you", | |
"artist": "black keys" | |
}, | |
{ | |
"song": "no rain", | |
"artist": "blind melon" | |
}, | |
{ | |
"song": "walls fall down", | |
"artist": "bedouin soundclash" | |
}, | |
{ | |
"song": "feel good inc.", | |
"artist": "gorillaz" | |
}, | |
{ | |
"song": "why\\'d you only callme ....", | |
"artist": "arctic monkeys" | |
}, | |
{ | |
"song": "back to the shack", | |
"artist": "weezer" | |
}, | |
{ | |
"song": "take me to church", | |
"artist": "hozier" | |
}, | |
{ | |
"song": "savior", | |
"artist": "rise against" | |
}, | |
{ | |
"song": "west coast", | |
"artist": "lana del rey" | |
}, | |
{ | |
"song": "breed", | |
"artist": "nirvana" | |
}, | |
{ | |
"song": "i sat by the ocean", | |
"artist": "queens of the stone age" | |
}, | |
{ | |
"song": "come to light", | |
"artist": "arkells" | |
}, | |
{ | |
"song": "i\\'m only joking", | |
"artist": "kongos" | |
}, | |
{ | |
"song": "time to pretend", | |
"artist": "mgmt" | |
}, | |
{ | |
"song": "archie, marry me", | |
"artist": "alvvays" | |
}, | |
{ | |
"song": "daughter", | |
"artist": "pearl jam" | |
}, | |
{ | |
"song": "hurricane", | |
"artist": "ms mr" | |
}, | |
{ | |
"song": "mr. brightside", | |
"artist": "killers" | |
}, | |
{ | |
"song": "scar tissue", | |
"artist": "red hot chili peppers" | |
}, | |
{ | |
"song": "riptide", | |
"artist": "vance joy" | |
}, | |
{ | |
"song": "hey ya!", | |
"artist": "outkast" | |
}, | |
{ | |
"song": "everlong", | |
"artist": "foo fighters" | |
}, | |
{ | |
"song": "headsick", | |
"artist": "july talk" | |
}, | |
{ | |
"song": "starlight", | |
"artist": "muse" | |
}, | |
{ | |
"song": "not your fault", | |
"artist": "awolnation" | |
}, | |
{ | |
"song": "trainwreck 1979", | |
"artist": "death from above 1979" | |
} | |
] |
This file contains 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 requests | |
from lxml import html | |
import json | |
def parse_song_info(song_info): | |
anchors = song_info.xpath('a') | |
artist = anchors[0].attrib['title'].lower() | |
song = anchors[1].attrib['title'].lower() | |
return dict(artist=artist, song=song) | |
def parse_songs(text): | |
tree = html.fromstring(text) | |
divs = tree.xpath('//div/div[@class="song-info"]') | |
return [parse_song_info(info) for info in divs] | |
def main(): | |
url = 'http://www.edge.ca/community/getLastPlayedSongs?num=1000' | |
page = requests.get(url) | |
songs = parse_songs(page.text) | |
print json.dumps(songs, indent=4) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment