Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
for loop for lyrics
#1
Hello everyone.

Can anyone help me with figuring out how to do the 'for loop' to automatically generate lyrics for each of the songs in a dataset which consists of n=2000 lines? I have Artist names and song titles in the dataset.

Would very much appreciate all and any help. Angel

thanks in advance!
Reply
#2
Hi,
I am not sure what you mean by generating. Do you want to randomly generate lyrics for songs? I suppose you want to extract the lyrics from lyric sites. Furthermore in what form do you get your data out of the database? How do you connect to the database and query data?
But lets assume that the data you get from the database is stored inside of an tuple inside of a list: songs = [("Disturbed", "Get down with the sickness"), ("Men without hats", "the safety dance")] and lets assume you crawl sites like azlyrics where you can provide the artist and song title in the url, like:
https://www.azlyrics.com/lyrics/menwitho...dance.html
Then you can use scrapy to extract the data from the sites.
Before that you could build your list of song-links like this:
songs = [("Disturbed", "Get down with the sickness"), ("Men without hats", "the safety dance")]
song_links = [f"https://www.azlyrics.com/lyrics/{artist.lower().replace(" ", "")}/{title.lower().replace(" ", "")}.html" for (artist, title) in songs]
Maybe you can show us what you already tried and what modules you are using Smile
Reply
#3
the content you are planning on scrapping is property of the site you are scrapping it from. they DO embed watermarks and they DO litigate infringement. they already sued google for stealing from rap genius. maybe you could tell us about where you are planning on copying the lyrics from? and also if this is for personal use, fair use, unlicensed distribution etc..
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020