【发布时间】:2017-07-05 01:05:49
【问题描述】:
<span rel="v:addr">
<span property="v:region">
<a href="https://tabelog.com/en/tokyo/">
123
</a>
</span>
<span property="v:locality">
<a href="https://tabelog.com/en/tokyo/A1317/A131710/rstLst/">
456
</a>
<a href="https://tabelog.com/en/rstLst/">
789
</a>
10
</span>
<span property="v:street-address">
</span>
</span>
我想提取 span 标签内没有任何空格的文本,并将其作为一个单独的字符串放在末尾。
我想要这个结果:
12345678910
下面是我的代码:
'AddressLocalityJap':"".join(response.xpath('normalize-space(//*[@id="anchor-rd-detail"]/section[1]/table/tbody/tr[4]/td/p[2]/span/span[2]//text()').extract())
【问题讨论】:
标签: python xml xpath web-crawler text-extraction