scrapy Acquisition - crawling Chinese distortion, into utf-8 GB2312

There was a time not how to use scrapy, and most recently acquired a web page, find the page code is gb2312,

Start taking the next search, has found a variety of operations, there is provided the settings  

# FEED_EXPORT_ENCODING = 'utf-8'
FEED_EXPORT_ENCODING = 'GB2312'

Have set encoding response.body of the spider, whereas I use response.xpath, here we found the problem still can not solve,

Finally found a method process_response Download MinddleWares, the requested data is returned in a modified coding middleware downloads to complete

response = HtmlResponse(url=response.url, body=response.body, encoding='utf-8')  
return response

 

Guess you like

Origin www.cnblogs.com/fly-kaka/p/12356891.html