V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
httpbin - 协议调试工具
httpstatuses - 协议状态码查询
httpie - cURL-like tool for humans
Fiddler
hahahalololo
V2EX  ›  HTTP

求教同样的 url 参数头部 cookies, scrapy 请求返回验证码, requests 直接请求就正常,代码如下

  •  
  •   hahahalololo · 114 天前 · 374 次点击
    这是一个创建于 114 天前的主题,其中的信息可能已经有所发展或是发生改变。
    url='xxxxxxxxxxxxxxx'
    
    yield scrapy.Request(
        url=url,
        cookies=self.cookies,
        headers=self.headers,
        meta={
        'download_timeout': 60  
        },
        callback=self.save,
    )
    
    rs = requests.get(url, headers=self.headers, cookies=self.cookies, timeout=60)
    

    这可能是什么原因造成的呢?找了一圈也没发现原因。COOKIES_ENABLED 设置成 True 的

    2 条回复    2024-01-09 18:09:16 +08:00
    laihan4396a
        1
    laihan4396a  
       114 天前
    抓个包,或者设置个代理,看下请求的区别?
    hahahalololo
        2
    hahahalololo  
    OP
       110 天前
    @laihan4396a 3q ,抓包后发现是 cookes 的问题,scrapy 框架对 cookies 自动处理了,少了许多
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2923 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:38 · PVG 22:38 · LAX 07:38 · JFK 10:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.