Created
November 10, 2015 16:41
-
-
Save JKirchartz/225d709f8e669dff8675 to your computer and use it in GitHub Desktop.
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 | |
from pyquery import PyQuery as pq | |
import re | |
from unidecode import unidecode | |
import optparse | |
def get_lyrics(band): | |
band = re.sub(r'\s','_',band) | |
url = "http://www.allthelyrics.com/lyrics/" + unidecode(band) | |
bandpage = pq(url=url) | |
bandpage.make_links_absolute() | |
for song in bandpage(".lyrics-list-item a"): | |
song_url = pq(song).attr("href") | |
lyrics = pq(url=song_url) | |
for lyric in lyrics(".content-text-inner"): | |
print re.sub(r'<[^>]+>',"",unidecode(pq(lyric).html())); | |
def main(): | |
p = optparse.OptionParser() | |
p.add_option("-b","--band", | |
help="Name of the Band to get lyrics from"); | |
options, arguments = p.parse_args() | |
band_name = options.band | |
get_lyrics(band_name) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment