scrapy how to set referer url

前端 未结 4 1935
旧时难觅i
旧时难觅i 2020-12-16 17:54

I need to set the referer url, before scraping a site, the site uses refering url based Authentication, so it does not allow me to login if the referer is not valid.

4条回答
  •  北海茫月
    2020-12-16 18:34

    If you want to change the referer in your spider's request, you can change DEFAULT_REQUEST_HEADERS in the settings.py file:

    DEFAULT_REQUEST_HEADERS = {
        'Referer': 'http://www.google.com' 
    }
    

提交回复
热议问题