思路:设置cookie并获取
port requests
base_url='http://httpbin.org'
cookie={'user':'wx','password':'123'}
r=requests.get(base_url+'/cookies',cookies=cookie)
print(r.text)
2.获取cookie
import requests
r=requests.get('http://www.baidu.com')
print(type(r.cookies))
print(r.cookies)
for key,value in r.cookies.items():
print(key+':'+value)
//设置cookieresponse.addHeader("Set-Cookie", "uid=112Path=/HttpOnly")
//设置多个cookie
response.addHeader("Set-Cookie", "uid=112Path=/HttpOnly")
response.addHeader("Set-Cookie", "timeout=30Path=/testHttpOnly")
//设置https的cookie
response.addHeader("Set-Cookie", "uid=112Path=/SecureHttpOnly")
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)