Answer the question
In order to leave comments, you need to log in
Why can't I change the encoding?
Hello. Started learning python and scrapy. I'm parsing the sitemap like this
# -*- coding: utf-8 -*-
from scrapy.spiders import SitemapSpider
class MySpider(SitemapSpider):
name = "jobs"
sitemap_urls = ['http://example.com/sitemap.xml']
def parse(self, response):
# print(response.body)
title = response.xpath('/html/body/div/div[1]/h1/text()').extract_first()
# y = title.encode("utf-8","ignore").decode("cp1251","ignore")
# y = title.encode("utf-8","ignore").decode("utf-8","ignore")
yield {'Title': title}
Answer the question
In order to leave comments, you need to log in
As a rule, all site components must support utf-8, both the web server and the DBMS, and the code is written in the same encoding, etc. I suggest you check everything one by one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question