【发布时间】:2015-10-08 05:41:09
【问题描述】:
我从 Web 链接抓取表格并希望通过删除所有脚本标记来重建表格。这是源代码。
response = requests.get(url)
soup = BeautifulSoup(response.text)
table = soup.find('table')
for row in table.find_all('tr') :
for col in row.find_all('td'):
#remove all different script tags
#col.replace_with('')
#col.decompose()
#col.extract()
col = col.contents
如何删除所有不同的脚本标签?以关注单元格为例,其中包括标签a、br和td。
<td><a href="http://www.irit.fr/SC">Signal et Communication</a>
<br/><a href="http://www.irit.fr/IRT">Ingénierie Réseaux et Télécommunications</a>
</td>
我的预期结果是:
Signal et Communication
Ingénierie Réseaux et Télécommunications
【问题讨论】:
标签: python html beautifulsoup html-parsing