【问题标题】:Python GET Request with set-cookies [duplicate]带有set-cookies的Python GET请求[重复]
【发布时间】:2019-09-07 05:19:48
【问题描述】:

我正在尝试使用需要先登录的python请求从网页中获取一些数据。登录http请求“响应头”包含“set-cookie”参数,用于网页的下一个http请求.有谁能告诉我如何将 set-cookie 用于网页的连续 GET 请求

【问题讨论】:

  • 如果你使用 requests 模块,r = requests.get(url, cookies=cookies)

标签: python python-requests


【解决方案1】:

试试这个

session = requests.Session()
response = session.get('http://google.com')
print(session.cookies.get_dict())

或者不使用会话使用

response = requests.get('http://google.com')
response.cookies

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-01
    • 2019-10-25
    • 1970-01-01
    • 1970-01-01
    • 2014-09-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多