lyrics.py
· 469 B · Python
Raw
import urllib,re,sys;
from BeautifulSoup import BeautifulSoup
inp = str(sys.argv[1])
a = urllib.urlopen("http://www.azlyrics.com/lyrics/" + inp + ".html").read()
soup = BeautifulSoup(a)
b = soup.findAll(style="margin-left:10px;margin-right:10px;")
c = str(b).replace("[<div", "<div")
c = c.replace("</div>]", "</div>")
meta = inp.split("/")
file = open(meta[0] + " - " + meta[1] + ".html", "w")
file.write(c)
file.close()
print "Success. Lyrics written to " + file.name
| 1 | import urllib,re,sys; |
| 2 | from BeautifulSoup import BeautifulSoup |
| 3 | inp = str(sys.argv[1]) |
| 4 | a = urllib.urlopen("http://www.azlyrics.com/lyrics/" + inp + ".html").read() |
| 5 | soup = BeautifulSoup(a) |
| 6 | b = soup.findAll(style="margin-left:10px;margin-right:10px;") |
| 7 | c = str(b).replace("[<div", "<div") |
| 8 | c = c.replace("</div>]", "</div>") |
| 9 | meta = inp.split("/") |
| 10 | file = open(meta[0] + " - " + meta[1] + ".html", "w") |
| 11 | file.write(c) |
| 12 | file.close() |
| 13 | print "Success. Lyrics written to " + file.name |