how to get the original start_url in scrapy (before redirect)

前端 未结 1 733
天涯浪人
天涯浪人 2021-02-13 12:26

I\'m using Scrapy to crawl some pages. I fetch the start_urls from an excel sheet and I need to save the url in the item.

class abc_Spider(BaseSpider):
   name =         


        
相关标签:
1条回答
  • 2021-02-13 12:47

    You can find what you need in response.request.meta['redirect_urls'].

    Quote from docs:

    The urls which the request goes through (while being redirected) can be found in the redirect_urls Request.meta key.

    Hope that helps.

    0 讨论(0)
提交回复
热议问题