class ForceUTF8Response(object):
    """A downloader middleware to force UTF-8 encoding for all responses."""
encoding = 'utf-8'

def process_response(self, request, response, spider):
    new_body = response.text.encode(self.encoding)
UnicodeEncodeError after setting restrict_xpaths settings