My Item class is as follows:
class SkeletonItem(scrapy.Item):
name = scrapy.Field()
In the parse() function of spider class, the logic is as follows:
soup = BeautifulSoup(response.body, 'html.parser')
si = SkeletonItem()
si['name'] = li.find("div", {"class": "info-panel"}).find("h2").text.encode('utf-8')
print si['name'] # str'中文'
print si # str'\u1234\u5678'
retirm si
As we can see, it outputs well when printing si['name'], whereas it merely shows unicode when printing si as a whole. The above phenomenon leads to the problem that when I write si to file, it only shows unicode in the file.
Could anyone give me some idea? Great thanks.