xpath匹配一个标签下所有内容

40次阅读

共计 218 个字符,预计需要花费 1 分钟才能阅读完成。

from lxml import etree
import requests

url = ‘http://www.shihuo.cn/youhui/474770.html#qk=youhui_list’
response = requests.get(url)
text = etree.HTML(response.text)

tt = text.xpath(“//div[@class=’article’]”)
info = tt[0].xpath(“string(.)”)

正文完
 0