Answer the question
In order to leave comments, you need to log in
How to parse the value of the desired td?
How to parse the "Manager's phone" value from the table if the table can have 2 or more lines with the same name, the number is not always at the very bottom of the table, and the number itself does not have a constant record format?
<div class="cnt">
<div class="cnt-in visible">
<table>
<tr>
<td>Полное наименование:</td>
<td><b>Открытое акционерное общество "Айсберг"</b></td>
</tr>
<tr>
<td>Краткое наименование:</td>
<td><b>ОАО "Айсберг"</b></td>
</tr>
<tr>
<td>Регион:</td>
<td><b>Республика Башкортостан</b></td>
</tr>
<tr>
<td>Часовой пояс:</td>
<td><b>0</b></td>
</tr>
<tr>
<td>Телефон руководителя:</td>
<td><b>(347) 223-52-65</b></td>
</tr>
phone = soup.find('div', class_='cnt-in visible').find_all("td")
Answer the question
In order to leave comments, you need to log in
parent = soup.find('td', string='Телефон руководителя:')
number = parent.find_next('td').text
Your approach is fundamentally wrong. To search for numbers, it is best to stupidly sort through the cells in the forehead and check the text for compliance with a regular expression. A correctly compiled regular expression will pull out all the phones for you without any problems, even if they are recorded in different formats.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question