美文网首页
利用lxml解析网站页面

利用lxml解析网站页面

作者: 8a8d7f2e842b | 来源:发表于2019-12-07 23:43 被阅读0次
import requests
from lxml import html
from html.parser import HTMLParser



response = requests.get('https://www.biquge.info/12_12696/5621986.html')
etree = html.etree
html = etree.HTML(response.content)
content= html.xpath('//*[@id="content"]')
content_tos = etree.tostring(content[0], pretty_print=True, method='html')
content_parse = HTMLParser().unescape(content_tos.decode())
print(content_parse)

相关文章

网友评论

      本文标题:利用lxml解析网站页面

      本文链接:https://www.haomeiwen.com/subject/mdmpgctx.html