图片如下,这是58同城的网页结构使用xpath 来解析如何同时获取到下面的6个字呢望大家帮忙看看
1
参考下面用 concat 来取,tr 改为你的 span,用 loop 来接起来
xpath.compile("concat (//tr["+i+"]/td[@class='name']/text(),' - ',//tr["+i+"]/td[not(@class='name')]/text())");
试试 Xpath 的 string 函数:提取多个子节点内容
tree.xpath('string(//p)')