python - 求教使用Tornado的HTTPClient登录HDOJ...怎么都登录不了不知道什么问题
阿神
阿神 2017-04-17 14:55:02
[Python讨论组]
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=,request_time=0.3185768127441406,time_info={})

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

阿神
阿神

闭关修行中......

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号