0
在scrapy蜘蛛上工作。在Scrapy Xpath中的逗號逗號
我有這個網站:
<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:
item['Description'] = sel.xpath('div[@class="content"]/div/div[@class="sliderContent"]//p').extract()
我想逃離逗號<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開始,非常感謝任何幫助!
請加網站的網址。我認爲你可以嘗試一些這樣的東西:>>> a ='一些內容,一些其他內容' >>> a.replace(',','/') '一些內容/一些其他內容' –