解决方案
1
from lxml import etree
div = etree.HTML(
html
)
table = div.xpath('//div/table')[0]
content = etree.tostring(table,print_pretty=True, method='
html'
2
from lxml.html import fromstring, tostring
# fromstring返回一个HtmlElement对象
# selector = fromstring(
html
html标签
original_html = tostring(content)
3
BeautifulSoup的find