求教使用Tornado的HTTPClient登录HDOJ...怎么都登录不了不知道什么问题,httpclienthdoj..,request = to


request = tornado.httpclient.HTTPRequest("http://acm.hdu.edu.cn/userloginex.php?action=login")request.method = 'POST'request.user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36"request.headers = {    "Accept": "*/*",    "Accept-Encoding": "gzip, deflate",    "Cache-Control": "max-age=0",    "Connection": "keep-alive",    "Content-Length": "44",    "Content-Type": "application/x-www-form-urlencoded",    "Host": "acm.hdu.edu.cn",    "Origin": "http://acm.hdu.edu.cn",    "Referer": "http://acm.hdu.edu.cn/",}request.body = "username=****&userpass=****&login=Sign+In"client = tornado.httpclient.HTTPClient()response = client.fetch(request)

就这样的方式,怎么都登录不了,可是POJ却能够成功登录,请问有什么问题?


response的内容

HTTPResponse(_body=None,buffer=<_io.BytesIO object at 0x7fb1a06a49a8>,code=200,effective_url='http://acm.hdu.edu.cn/userloginex.php?action=login',error=None,headers={'Set-Cookie': 'PHPSESSID=sm6dbdatftbmh0u4jg96r1h5u3; path=/', 'Cache-Control': 'no-cache, must-revalidate', 'Last-Modified': 'Sat, 16 May 2015 09:01:41 GMT', 'X-Cache': 'MISS from wwwcache2.hdu.edu.cn', 'Expires': 'Mon, 14 Feb 1983 10:10:00 GMT', 'Server': 'Apache', 'Connection': 'keep-alive', 'Pragma': 'no-cache', 'Date': 'Sat, 16 May 2015 09:01:41 GMT', 'P3p': 'CP=CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR', 'Vary': 'Accept-Encoding', 'Content-Length': '2947', 'X-Consumed-Content-Encoding': 'gzip', 'Content-Type': 'text/html', 'X-Powered-By': 'PHP/5.3.29', 'Via': '1.1 wwwcache2.hdu.edu.cn (squid/3.4.13)'},reason='OK',request=<tornado.httpclient.HTTPRequest object at 0x7fb1a4859240>,request_time=0.3185768127441406,time_info={})

response的body里面是登录页面,登录页面中显示并没有登录成功

编橙之家文章,

评论关闭