I am parsing some paragraphs in a table.
Here’s the content and code.
txt = '''
<head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head><table><tr><th filter=all>Employee Name</th><th filter=all>Project Name</th><th filter=all>Area</th><th filter=all>Date</th><th filter=all>Employee Manager</th></tr>
<tr><td style="vnd.ms-excel.numberformat:@">David</td><td style="vnd.ms- excel.numberformat:@">Review-2016</td><td style="vnd.ms- excel.numberformat:@">US</td><td align=right>17/03/2016</td><td style="vnd.ms- excel.numberformat:@">Andrew</td></tr>
<tr><td style="vnd.ms-excel.numberformat:@">Kate</td><td style="vnd.ms-excel.numberformat:@">Review 2016</td><td style="vnd.ms-excel.numberformat:@">UK</td><td align=right>21/03/2016</td><td style="vnd.ms-excel.numberformat:@">Liz</td></tr>
'''
soup = BeautifulSoup(txt, "lxml")
soup.prettify()
list_5 = soup.find_all('table')[0].find_all("tr")
for row in list_5:
for nn in row.find_all("td"):
print nn.text
So far the texts are got but all in together, i.e.:
David
Review-2016
US
17/03/2016
Andrew
Kate
Review 2016
UK
21/03/2016
Liz
What’s needed is in column forms, like David, Kate or US, UK etc.
Can you help me with the right way? Thank you.