I have a table data like this:
<table class="tablesorter" id="dea">
<thead>
<tr>
<th class="header ">Name</th>
<th class="header">City</th>
<th class="">Address</th>
<th class="">Phone Nos</th>
<th class="">Email</th>
<th class="">Fax</th>
</tr>
</thead>
<tbody>
<tr class="info">
<td style="font:bold 12px Tahoma; color:#1f2c48;">Audi California</td>
<td> California </td>
<td align="left">
A?85, bay Area, Phase 1, <br>
California<br>
California
- 6554655
</td>
<td align="right">
<br>4747744747<br>108388383
</td>
<td align="center">
info<!-- >@_ -->@<!-- >@_ -->audiCal<!-- >@_ -->.<!-- >@_ -->net
</td>
<td align="right">
</td>
</tr></tbody>
</table>
I am using beautifulsoup to parse this, but now I got into problem while fetching data from last four <td>
. Whenever I read their values using .string
property, I get None
as value. I guess this is because they have <br>
tags. I want last four <td>
data that has address, phone no., email_id and fax. Instead of .string
what should I use to get all those data?
You can use .text
for getting the text.
Edit:
Another option may be getting every element using .contents
and joining them as necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With