我正在使用Scrapy从新闻网站抓取文章,并将其添加到mongoDB。但是在插入时,我在MongoDb中得到了这样的unicode字符
"article": "Satya Nadella, Microsoft\u2019s executive vice president of cloud and enterprise, has just been named the company\u2019s next CEO.
我试过了
FEED_EXPORT_ENCODING = "utf-8"
但它只在我运行crawler并将数据导出为JSON文件时起作用,在MongoDB中存储数据时不起作用
在蜘蛛.py文件我写了这行代码来获取文章
item["article"]=response.xpath('//p/text()').getall()
item["article"] =' '.join(item['article'])
如何用ASCII等效字符替换这些字符?你知道吗
这个解决方案对我有效(Character encoding in python to replace 'u2019' with ')
相关问题 更多 >
编程相关推荐