为什么我不能在post方法中使用python登录此站点
这是我使用python登录站点的代码:为什么我不能在post方法中使用python登录此站点,python,login,urllib2,cookielib,Python,Login,Urllib2,Cookielib,这是我使用python登录站点的代码: import urllib2, cookielib cookie_support= urllib2.HTTPCookieProcessor(cookielib.CookieJar()) opener = urllib2.build_opener(cookie_support, urllib2.HTTPHandler) urllib2.install_opener(opener) content = urllib2.urlopen('http://192.1
import urllib2, cookielib
cookie_support= urllib2.HTTPCookieProcessor(cookielib.CookieJar())
opener = urllib2.build_opener(cookie_support, urllib2.HTTPHandler)
urllib2.install_opener(opener)
content = urllib2.urlopen('http://192.168.1.200/order/index.php?op=Login&ac=login&userName=%E8%B5%B5%E6%B1%9F%E6%98%8E&userPwd=123').read()
print content
它显示:
{"title":"login error","body":"username or password error","data":{"status":1}}
但是用户名和密码是正确的,我可以使用firefox登录这个网站
那我该怎么办
谢谢尝试使用密码管理器: 发件人:
尝试使用密码管理器: 发件人:
您正在发出GET请求。要发出POST请求,请使用:
content = urllib2.urlopen(
'http://192.168.1.200/order/index.php",
'op=Login&ac=login&userName=%E8%B5%B5%E6%B1%9F%E6%98%8E&userPwd=123').read()
如果数据(第二个参数)被传递给
urlopen
方法,则该方法将发送POST请求。您正在发出GET请求。要发出POST请求,请使用:
content = urllib2.urlopen(
'http://192.168.1.200/order/index.php",
'op=Login&ac=login&userName=%E8%B5%B5%E6%B1%9F%E6%98%8E&userPwd=123').read()
如果数据(第二个参数)被传递给urlopen
方法,则该方法将发送POST请求