html 文本解码 xpath 获取html标签

import html
import etree
url_h2 = selector.xpath("//a[@_stat='video:poster_v']/../h2")[0]
url_div = selector.xpath("//a[@_stat='video:poster_v']/../div")[0]
url_h2 = etree.tostring(url_h2).decode()
url_div = etree.tostring(url_div).decode()
print("******", url, url_img, html.unescape(url_h2), html.unescape(url_div))

猜你喜欢

转载自www.cnblogs.com/guanong/p/10363545.html