new to SO and having some difficulty with scraping a table from a website using beautifulsoup.
The source html of the table goes something like this (repeated ad-nauseum for every artist/song/album):
<td class="subject">
<p title="song">song</p>
<p class="singer" title="artist | album">artist<span class="bar">|</span>album</p>
</td>
And I'm trying to create an output file with all of that information. The code I'm using is:
with open('output.txt', 'w', encoding='utf-8') as f:
for tr in soup.find_all('tr')[1:]:
tds = tr.find_all('td')
f.write("Information: %s" % tds[3].text)
which gets me an output like so:
Information:
song
singer | album
How do I change this to have it all on one line, and to also separate it properly? Ideally my output should be like this:
Song Title: song
Artist: singer
Album Name: album