Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何检查我是否';我是否登录了?_Python_Python 2.7_Python Requests - Fatal编程技术网

Python 如何检查我是否';我是否登录了?

Python 如何检查我是否';我是否登录了?,python,python-2.7,python-requests,Python,Python 2.7,Python Requests,我想测试这个请求是否有效。在请求上使用会话时,是否有方法检查html或执行类似geturl()的操作 #!/usr/bin/env python 2.7.11 # import requests headers = {'User-Agent': 'Mozilla/5.0'} cookie = {'enwiki_session': '17ab96bd8ffbe8ca58a78657a918558'} url = 'https://127.0.0.1/login.php' payloa

我想测试这个请求是否有效。在请求上使用会话时,是否有方法检查html或执行类似geturl()的操作

#!/usr/bin/env python 2.7.11
#
import requests


headers = {'User-Agent': 'Mozilla/5.0'}

cookie = {'enwiki_session': '17ab96bd8ffbe8ca58a78657a918558'}


url = 'https://127.0.0.1/login.php'


payload = {'user': 'admin','pass': 'admin123'}


Page = requests.Session()
Page.post(url,headers=headers,cookies=cookie,data=payload)

#print Page.content
#print Page.geturl()

看看回复内容?你肯定知道成功登录是什么样子的吗?有没有办法让我在post请求后检查脚本当前在哪个链接上?类似于geturl()的内容您的意思是
p=Page.post(url,headers=headers,cookies=cookie,data=payload)
print p.url