我使用JavaScript创建了cookie,然后重新加载页面,并使用Python检索cookie,但检索到的唯一cookie是会话cookie
添加Cookie:
function changeFeatures() {
document.cookie = "byteName=" + document.getElementById("byteName").value+"; path=/";
document.cookie = "byteDescription=" + document.getElementById("byteDescription").value+"; path=/";
document.cookie = "byteType=" + document.getElementById("byteType").value+"; path=/";
document.cookie = "byteEndian=" + document.getElementById("byteEndian").value+"; path=/";
document.cookie = "byteParent=" + document.getElementById("byteParent").value+"; path=/";
document.cookie = "byteOffset=" + document.getElementById("byteOffset").value+"; path=/";
document.cookie = "byteLength=" + document.getElementById("byteLength").value+"; path=/";
location.reload();
}
正在检索Cookie:
import requests
r = requests.get('http://localhost:5000/)
print(r)
c = r.cookies
print(c)
i = c.items()
print(i)
r打印:
Response [200]
c打印:
RequestsCookieJar[]
我打印:
[('session', 'eyJfZmxhc2hlcyI6W3siIHQiOlsibWVzc2FnZSIsIlBsZWFzZSBsb2cgaW4gdG8gYWNjZXNzIHRoaXMgcGFnZS4iXX1dLCJfZnJlc2giOmZhbHNlfQ.XJEbzA.2QOTc9iPNBD_RSEVgAdnvR36chE')]
我想出来了。我应该使用python中的
request.cookie
来检索cookie,因为我使用的是Flask相关问题 更多 >
编程相关推荐