【发布时间】:2023-03-29 13:19:01
【问题描述】:
我想从网上抓取一张表格并保留 实体完整,以便我以后可以重新发布为 HTML。 BeautifulSoup 似乎正在将这些转换为空格。示例:
from bs4 import BeautifulSoup
html = "<html><body><table><tr>"
html += "<td> hello </td>"
html += "</tr></table></body></html>"
soup = BeautifulSoup(html)
table = soup.find_all('table')[0]
row = table.find_all('tr')[0]
cell = row.find_all('td')[0]
print cell
观察结果:
<td> hello </td>
要求的结果:
<td> hello </td>
【问题讨论】:
标签: python web-scraping beautifulsoup html-parsing html-entities