first python program.. lyrics search

G

Gustavo Rahal

Hi

I'm trying to learn python by doing something that I think it would be
nice; Search lyrics using some websites like www.musicsonglyrics.com,
http://www.sing365.com
I am trying to parse the html code and get the information that i need.
Since I am not very good with programing I am stuck on this part.
Let's take the www.musicsonglyrics.com website as an example. So let's
say Metallica lyrics would be on www.musicsonglyrics.com/M.htm. Getting
the first letter, requesting the M.htm page and checking if Metallica is
in the html code is easy. Here is what I did up to now:

artist = raw_input("Name of the artist: ")
music = raw_input("Name of the music: ")


url = "http://www.musicsonglyrics.com/" + artist[0].capitalize() + ".htm"
f =
urllib2.urlopen(url)

found = 0
lines = f.readlines()
f.close()
for x in lines:
if x.find(artist) != -1:
found = 1



if found:
print "OK"
else:
print "No"


The problem is once I have the M.htm page I don't now how to get from
the html code the "http://www.musicsonglyrics.com/M/Metallica/Metallica
lyrics.htm" link to proceed with the search. I tried to read about
Regular Expressions but I think I'm to dumb for it.

Any ideas? Maybe my approach is completely wrong....

Appreciate any help
Gustavo
 
M

Mel Wilson

Hi

I'm trying to learn python by doing something that I think it would be
nice; Search lyrics using some websites like www.musicsonglyrics.com,
http://www.sing365.com [ ... ]
The problem is once I have the M.htm page I don't now how to get from
the html code the "http://www.musicsonglyrics.com/M/Metallica/Metallica
lyrics.htm" link to proceed with the search. I tried to read about
Regular Expressions but I think I'm to dumb for it.

Any ideas? Maybe my approach is completely wrong....

Look up htmllib in Python libraries. It's not a small
job, but you'll have learned a lot by the time you've
finished.

Good Luck. Mel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top