Lea*_*AWK 5 xpath scrapy-spider
对于以下代码:
<a class="title" href="the link">
Low price
<strong>computer</strong>
you should not miss
</a>
Run Code Online (Sandbox Code Playgroud)
我使用此xpath代码进行抓取:
response.xpath('.//a[@class="title"]//text()[normalize-space()]').extract()
Run Code Online (Sandbox Code Playgroud)
我得到以下结果:
u'\n \n Low price ', u'computer', u' you should not miss'
Run Code Online (Sandbox Code Playgroud)
为什么\n在此示例中low price没有删除之前的两个空白空间normalize-space()?
另一个问题:如何将这三个零件合并为一个刮板u'Low price computer you should not miss'?
| 归档时间: |
|
| 查看次数: |
1454 次 |
| 最近记录: |