V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
hahahalololo
V2EX  ›  问与答

大佬们, scrapy 请求会自动跳转的 url,跳转后的新 url 请求,不会带上 cookies,请问怎么弄才能跳转后也带上 cookies

  •  
  •   hahahalololo · Jan 9, 2024 · 1266 views
    This topic created in 845 days ago, the information mentioned may be changed or developed.
    yield scrapy.Request(
        url=url,
        cookies=self.cookies,
        headers=self.headers,
        meta={
        'download_timeout': 60  # 请求超时
        },
        callback=self.read_table,
    )
    

    请求这个 url ,会 302 自动生成一个新的 url 去请求,但是请求新 url 的时候,发现它的 cookies 变成空的了,导致请求失败,求教该怎么做才能解决这个问题。

    Supplement 1  ·  Jan 10, 2024
    新旧 url 都是同个域名下的,不是跨域
    2 replies    2024-01-10 09:56:39 +08:00
    himarrin
        1
    himarrin  
       Jan 10, 2024
    COOKIES_ENABLED = True
    hahahalololo
        2
    hahahalololo  
    OP
       Jan 10, 2024
    @himarrin 3q ,但这个我之前就试过,真,假,注销三种都试了,无效
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2592 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 14:45 · PVG 22:45 · LAX 07:45 · JFK 10:45
    ♥ Do have faith in what you're doing.