当我尝试检查cookie是否存在时,我遇到了以下问题。
import requests
username = raw_input('Please enter your username: ')
password = raw_input('Please enter your password: ')
DATA = {
"url": "http://example.com/index.php",
"action": "do_login",
"submit": "Login",
"quick_login": "1",
"quick_username": (username),
"quick_password": (password),
}
requests.post("http://example.com/member.php", data=DATA)
if 'mybbuser' in request.COOKIES.keys():
print("Correct")
else:
print("Wrong")
我得到的错误:
NameError:未定义名称“请求”
答案 0 :(得分:0)
也许您需要存储响应并在那里查找Cookie:
resp = requests.post(...)
if resp.cookies['blahblah']:
答案 1 :(得分:0)
我认为您只需将其更改为requests
而不是request
。