为一只发痒的蜘蛛工作。在
我有这个html:
<div class="sliderContent">
<p>some content, some other content</p>
<p>some content, some other content</p>
<p>some content, some other content</p>
<p>some content, some other content</p>
</div>
我的xpath:
^{pr2}$我想转义<p>
中的逗号并提取所有内容,保留html。我试过了:
def parse_dir_contents(self, response):
for sel in response.xpath('//div[@class="container"]'):
item = LuItem()
item['Description'] = sel.xpath('div[@class="content"]/div/div[@class="sliderContent"]//p').extract()[0].replace(',','\,')
yield item
这显然适用于第一个<p>
,但是我如何才能为所有<p>
实现这一点呢?在
从python开始,任何帮助都非常感谢!在
您的分析结果是一个列表,您只修改了列表[0]中的第一个元素,您需要浏览整个描述列表:
相关问题 更多 >
编程相关推荐