Use existing authenticated session from browser to perform https request on python

后端 未结 3 1506
礼貌的吻别
礼貌的吻别 2021-02-15 11:17

Is it possible to take an existing logged in session (say in Chrome) and pipe that session to a python script to perform an https request?

To be clear on what I want to

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-15 11:55

    This might help

    jar = requests.cookies.RequestsCookieJar([
    {
        "domain": ".stackoverflow.com",
        "expirationDate": "1427212131.77312",
        "hostOnly": "false",
        "httpOnly": "true",
        "name": "usr",
        "path": "/",
        "secure": "false",
        "session": "false",
        "storeId": "0",
        "value": "SOMEVALUE",
        "id": "5"
    }]
    requests.get(url, headers=headers, cookies=jar)
    

    @Stupid.Fat.Cat Let me know what worked for you

提交回复
热议问题