How to print html output each on its line in python? -


so i'm making alittle project beginner , i'm doing webscraping. wanted print lyrics of song each on it's line using beautifulsoup in python instead it's printing this:

i looked out morning , sun goneturned on music start dayi lost myself in familiar songi closed eyes , slipped awayit's more feeling (more feeling)when hear old song used play (more feeling)and begin dreaming (more feeling)till see marianne walk awayi see marianne walkin' awayso many people have come , gonetheir faces fade years go byyet still recall wander onas clear sun in summer skyit's more feeling (more feeling)when hear old song used play (more feeling)and begin dreaming (more feeling)till see marianne walk awayi see marianne walkin' awaywhen i'm tired , thinking coldi hide in music, forget dayand dream of girl used knowi closed eyes , slipped awayshe slipped awayit's more feeling (more feeling)when hear old song used play (more feeling)and begin dreaming (more feeling)till see marianne walk away

this code:

import urllib bs4 import beautifulsoup  html = urllib.urlopen("http://www.metrolyrics.com/more-than-a-feeling-lyrics-boston.html")  bsobj = beautifulsoup(html, "lxml")  namelist = bsobj.find_all("div", {"id": "lyrics-body-text"})  print("".join([p.get_text(strip=true) p in namelist])) 

try writing simple loop

for p in namelist:     print(p.get_text(strip=true)) 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -