469,353 Members | 2,149 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,353 developers. It's quick & easy.

first python program.. lyrics search

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
Jul 18 '05 #1
1 1614
In article <ma**************************************@python.o rg>,
Gustavo Rahal <li****@grahal.net> wrote:
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.
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

28 posts views Thread by Jay | last post: by
35 posts views Thread by Michel Sanner | last post: by
9 posts views Thread by News | last post: by
reply views Thread by Wilbert Berendsen | last post: by
19 posts views Thread by John Salerno | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.