I run this code (just a few times) and I have no problem getting the data.
It is similar to your code, so I do not know why you have problems.
Perhaps for some reason they blocked you.
import scrapy
import json
class MySpider(scrapy.Spider):
name = 'myspider'
allowed_domains = ['www.myntra.com']
start_urls = ['https://www.myntra.com/web/v2/search/data/duke']
def parse(self, response):
print('url:', response.url)
data = json.loads(response.body)
print('data.keys():', data.keys())
print('meta:', data['meta'])
print("data['data']:", data['data'].keys())
from scrapy.crawler import CrawlerProcess
c = CrawlerProcess({
'USER_AGENT': 'Mozilla/5.0',
'FEED_FORMAT': 'csv',
'FEED_URI': 'output.csv',
})
c.crawl(MySpider)
c.start()
furas source
share