jeudi 30 mai 2019

Get contents of a particular row

I want to locate 'td' where text is 'xyz' so that I can find other attributes in the row. I only have 'xyz' with me and want to get other elements in that row.

. . .

<tr>
    <td>
        <a>xyz</a>
    </td>
    <td>address</td>
    <td>phone number</td>
</tr>

. . .

I can get 'xyz' easily by using required = soup.find('a', text = 'xyz') print(required[0].text)

but I'm not able to locate 'td' so that I can use find_next_siblings() to get other columns.

Expected output: xyz address phone number




Aucun commentaire:

Enregistrer un commentaire