刮刮如何设置引荐网址 [英] scrapy how to set referer url

查看:44
本文介绍了刮刮如何设置引荐网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要设置引用网址,在抓取网站之前,该网站使用基于引用网址的身份验证,因此如果引用网址无效,则不允许我登录.

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.

有人能告诉如何在 Scrapy 中做到这一点吗?

Could someone tell how to do this in Scrapy?

推荐答案

如果你想改变蜘蛛请求中的referer,你可以改变DEFAULT_REQUEST_HEADERSsettings.py 文件中:

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' 
}

这篇关于刮刮如何设置引荐网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆