标签:cookie ros ref oss ast art dom request else
1: 发送带 cookie 的 请求
resp = requests.get(self.url_item_list_first_page, cookies=self.cookies)
>>> url = ‘http://httpbin.org/cookies‘ >>> cookies = dict(cookies_are=‘working‘) >>> r = requests.get(url, cookies=cookies) >>> r.text ‘{"cookies": {"cookies_are": "working"}}‘
>>> jar = requests.cookies.RequestsCookieJar() >>> jar.set(‘tasty_cookie‘, ‘yum‘, domain=‘httpbin.org‘, path=‘/cookies‘) >>> jar.set(‘gross_cookie‘, ‘blech‘, domain=‘httpbin.org‘, path=‘/elsewhere‘) >>> url = ‘http://httpbin.org/cookies‘ >>> r = requests.get(url, cookies=jar) >>> r.text ‘{"cookies": {"tasty_cookie": "yum"}}‘
官网源码: http://docs.python-requests.org/zh_CN/latest/user/quickstart.html#cookie
标签:cookie ros ref oss ast art dom request else
原文地址:https://www.cnblogs.com/sanmubird/p/9208877.html