here is the HTML content:
Expression | <Solution 1:
Use .stripped_strings
to get the 'interesting' text from a table row:
rows= table.find_all('tr', class_=('rowLight', 'rowDark'))
forrowinrows:
print list(row.stripped_strings)
This outputs:
[u'Task1', u'Assigned to', u'Harry']
[u'Task2', u'Rejected by', u'Lopa']
[u'Task5', u'Accepted By', u'Mathew']
or, to pull everything into one list of lists (with, by request, the last row not included):
data = [list(r.stripped_strings) for r in rows[:-1]]
which becomes:
data = [[u'Task1', u'Assigned to', u'Harry'], [u'Task2', u'Rejected by', u'Lopa']]
The result of .find_all()
, a ResultSet
, acts just like a Python list and you can slice it at will to ignore certain rows, for example.
---|
Post a Comment for "Confusion To Read Html Table Contents Using Beautifulsoup?"