How to add Headers to Scrapy CrawlSpider Requests?

后端 未结 2 1117
迷失自我
迷失自我 2020-12-17 23:50

I\'m working with the CrawlSpider class to crawl a website and I would like to modify the headers that are sent in each request. Specifically, I would like to add the refer

2条回答
  •  攒了一身酷
    2020-12-18 00:02

    You can pass REFERER manually to each request using headers argument:

    yield Request(parse=..., headers={'referer':...})
    

    RefererMiddleware does the same, automatically taking the referrer url from the previous response.

提交回复
热议问题