動態

詳情 返回 返回

xpath匹配一個標籤下所有內容

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(.)")

user avatar
0 用戶, 點贊了這篇動態!

發表 評論

Some HTML is okay.