Answer the question
In order to leave comments, you need to log in
JSON does not write the received data correctly. How to solve the problem?
I am trying to parse the page by running the code:
import scrapy
class NewSpider(scrapy.Spider):
name = "new"
start_urls = [
'https://tsum.ua/ua/nova-kolekcija.html',
]
def parse(self, response):
for category in response.xpath('//div[@class="product-detail-content"]'):
yield{
'name': category.xpath('h5[@class="product-item-brand-name"]/a[@class="product-item-link"]/text()').extract(),
'deskription': category.xpath('h5[@class="product name product-item-name"]/a[@class="product-item-link"]/text()').extract(),
}
scrapy crawl new -o alles.jsonI get what is needed:
{'name': ['\n REDValentino '], 'deskription': ['Джинси']}
{"name": ["\n REDValentino "], "deskription": ["\u0417\u0430\u043c\u0448\u0435\u0432\u0456 \u043c\u044e\u043b\u0456"]},
Answer the question
In order to leave comments, you need to log in
Well, firstly, \u-notation is found not only in python , but also in JSON as such . It is enough to drive into the terminal of the python
print("\u0417\u0430\u043c\u0448\u0435\u0432\u0456 \u043c\u044e\u043b\u0456")
to make sure the string is ok. The machine will read it without problems. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question