import requests
from lxml import etree
from lxml import html
from html.parser import HTMLParser
response = requests.request("GET", url, headers=headers, data = payload, verify=False)
# print(response.text)
HTML = etree.HTML(response.content.decode())
a= HTML.xpath('//*[@id="js_content"]')
name1 = html.tostring(a[0])
name2 = HTMLParser().unescape(name1.decode())
print(name2)
提取html某节点下包含标签的内容(HTMLParser库)
最新推荐文章于 2021-06-21 16:38:45 发布