This shows you the differences between two versions of the page.
ii:labs:s2:01:tasks:05 [2023/03/17 21:30] florin.stancu removed |
ii:labs:s2:01:tasks:05 [2024/03/15 13:30] (current) florin.stancu [05. [20p] Bonus: Lyrics retrieval] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== 05. [10p] Feedback ==== | + | ==== 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 [[https://www.versuri.ro/artist/florin-salam/|this site]]. | ||
+ | <note> | ||
+ | Ofc, you can do this very easy using the ''[[https://requests.readthedocs.io/en/latest/|requests]]'' library! | ||
+ | (Note: you must first install it using ''pip''). | ||
+ | </note> | ||
+ | * 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). | ||
+ | <note> | ||
+ | Although you could use [[https://docs.python.org/3/library/re.html|regular expressions]] for capturing the contents inside a specific HTML tag, it's a bit overkill... | ||
+ | |||
+ | Instead: simply use the standard [[https://docs.python.org/3/library/stdtypes.html#string-methods|string search methods]] and Python sequence indexing / slices to accomplish this much easier ;) | ||
+ | </note> | ||
- | Please take a minute to fill in the [[https://forms.office.com/Pages/ResponsePage.aspx?id=usiMLdqNNEOeXPrCCS6brJoxNMaLqNZHpd8YaA7IhDNURElGNjIzNTEwUlNRS0cyQlkxQk5LMldINC4u|feedback form]] for this lab. | ||