[Python] Robobrowser won't change cookies

Discussão em 'Python' iniciado por Stack, Agosto 18, 2025.

  1. Stack

    Stack Membro Participativo

    I have a POST request sent to server from robobrowser, and the server responds with no data. The response headers are as follows (this is the response from Chrome browser and it's the way it supposed to be):

    Cache-Control:no-cache, no-store, must-revalidate
    Content-Length:335
    Content-Type:application/json; charset=utf-8
    Date:Wed, 02 Aug 2017 17:01:17 GMT
    Expires:-1
    lg:2673
    Pragma:no-cache
    Server:Unknown
    Set-Cookie:BrandingUserLocationGroupID=ic4DUh/NXVp8VOKAtyDgbA==; expires=Fri, 01-Sep-2017 17:01:16 GMT; path=/; secure; HttpOnly
    Set-Cookie:.AIRWATCHAUTH=A69C1A5EE8A5F3626385F35DA1B104EE7DFF5E5AF549DDB02EE8ED53931A0585C0FBB8299E3FC7B428A982B9826EF68390E659F4A74DCE00E195601F400D6E69F53907DADED4194F32DD08A72BA212DCCD0D23AB7C5BD56171E6C55EF1BE90849E9C81B2DAE23B05CA6E361326F44604; expires=Thu, 03-Aug-2017 17:01:17 GMT; path=/; secure; HttpOnly
    Strict-Transport-Security:max-age=31536000;includeSubDomains
    user:5679
    X-Content-Type-Options:nosniff
    x-download-options:noopen
    x-frame-options:SAMEORIGIN
    X-XSS-Protection:1; mode=block


    it looks like server is resetting cookies, but my robobrowser instance does not respond/refresh to new cookies. basically, the website is trying to switch sessions/change cookies I think, but my python robobrowser does not reflect that or does not allow it to change for some reason

    Here is my POST request and response:

    browser=RoboBrowser()
    browser.session.headers['X-Requested-With']='XMLHttpRequest'
    browser.open('https://example.com/test/Users/set-role?id='+role_id+'&__RequestVerificationToken='+token,method='POST')
    print browser.response.content


    This gives me the following error message:

    {"RedirectUrl":null,"IsSuccess":false,"Message":"Save Failed","CustomMessage":null,"Errors":[{"Key":"","Value":["An error has occurred. This error has automatically been saved for further analysis. Please contact technical support."]}],"Messages":{},"HasView":false,"ViewHtml":null,"ViewUrl":null,"IsValidationException":false,"IsValidationWarning":false,"ReloadPage":false,"IsSessionExpired":false,"Script":null,"NextWizardUrl":null,"PreviousWizardUrl":null,"ShowDialog":false}


    Does anyone know how to get robobrowser to respond to new cookies?

    Added screenshot of cookie from Developer Tools in Chrome. The red box highlighted is where the change occurs once the link is clicked. [​IMG]

    Continue reading...

Compartilhe esta Página