7
我想从网上刮一张桌子,并保持& nbsp;实体完好无损,以便稍后可以重新发布为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>
感谢您的回答:) – 2013-04-28 03:56:10