By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,547 Members | 1,417 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,547 IT Pros & Developers. It's quick & easy.

first python program.. lyrics search

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.