我正在使用 python 框架 scrapy 来抓取数据,这是我的蜘蛛的代码:
def parse(self, response):
hxs = HtmlXPathSelector(response)
sites = hxs.select('//h1')
links = hxs.select('//div[@class="pp-title"]')
#sites = hxs.select('//div[@id="yt-lockup-content"] ')
items = []
for site in links:
item = DmozItem()
item['title'] = site.select('a/h1/text()').extract()
item['link'] = site.select('a/@href').extract()
items.append(item)
return items
items.json
我用这个蜘蛛收集数据,我用命令运行蜘蛛scrapy crawl dmoz -o items.json -t json
。数据以格式存储
[[{"link": ["http://www.ponudadana.hr/Planinarski-dom-Kalnik-2-dana-s-doruckom-za-dvoje-za-149kn-umjesto-300kn-7482_1"], "title": ["Planinarski dom Kalnik - 2 dana s doru\u010dkom za dvoje za 149kn umjesto 300kn!"]},
问题是特殊字符 likeč,ž,š,đ,ž
被存储为\u010
或类似,例如看到上面的单词doru\u010dkom
,它应该是doručkom
. 谁能帮助我,我应该使用一些编码格式吗?