это фрагмент страницы , строк очень много в таблице поэтому и цикл.
#!/usr/bin/env python3 import urllib.request import requests from bs4 import BeautifulSoup import re rows = ['<html><head><title>Page title</title></head><table class="adv_table">' '<tr>' '<td style="color: #333; font-size: 11px;"> <span class="price_realty_table"><b>1 660 000</b></span> <div class="owner_stile">Аэропрот</div> </td>', '<td align="center"> <span style="white-space:nowrap;"><b> 8 (555) 555-55-88</span><br/><span> 8 (555) 555-31-88</span> </b></td>', '<td align="center" id="td_statDaily_255729_1" style="color: #000000; font-size: 10px;">ЭКРАН<strong>195</strong> <a class="link_modal_details" href="javascript:realty.getStatDaily( 255629, 1 );">детали</a><br/> <a class="nyroModal" href="#statDaily_255629_1" style="display: none;">детали</a> <div id="div_statDaily_255729_1"></div> </td>', '<td align="center" style="border-right:0"> <input class="ids_actions" name="ids_action[]" type="checkbox" value="255629"/> </td></tr></table></html>'] soup = BeautifulSoup(''.join(rows)) table = soup.find('table', class_='adv_table') rows = table.find('tr') for row in rows: cols = row.findAll('td') print(cols[1].b.text)
выдает ошибку
Traceback (most recent call last):
File “probe.py”, line 25, in <module>
print(cols.b.text)
IndexError: list index out of range