用python中的xpath怎么获取我想要标记的内容

2025-05-01 18:32:27
推荐回答(1个)
回答1:

response.xpath('//h3/a/descendant-or-self::text()[normalize-space()]')
descendant-or-self表明当前node和子代nodes
normal-space()去掉whitespace-only nodes的子代nodes