python - 求教使用Tornado的HTTPClient登录HDOJ...怎么都登录不了不知道什么问题

 坏坏不贱_233 发布于 2022-11-02 17:47
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里面是登录页面,登录页面中显示并没有登录成功

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有