05. [10p] Bonus: Lyrics retrieval

What else can you do easily using Python… ?

Let's try this one:

  • fetch the lyrics of your favorite song from this site.

Ofc, you can do this very easy using the requests library! (Note: you must first install it using pip).

  • Extract just the lyrics part from the HTML code and print it to the console! (also, please get rid of those <br> line break tags, replace them with newlines instead).

Although you could use regular expressions for capturing the contents inside a specific HTML tag, it's a bit overkill…

Instead: simply use the standard string search methods and Python sequence indexing / slices to accomplish this much easier ;)

ii/labs/s2/01/tasks/05.txt · Last modified: 2024/03/15 13:30 by florin.stancu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0