python asp.net requests_python3使用requests访问asp页面时出错,返回500
学校的官微有个一键查成绩的功能,我一直很想能做出来玩,现在在学习python,正好准备拿来练手,但是访问的时候却出现了500错误。
以下是代码:
python
import requests
import time
import hashlib
from user import user
url1 = 'http://202.115.133.173:805/Common/Handler/UserLogin.ashx'
url2 = 'http://202.115.133.173:805/Default.aspx'
url3 = 'http://202.115.133.173:805/MyMessage/MyMsgForm.aspx'
username = user.name
password = user.pwd
sign = int(time.time()*1000)
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate, compress',
'Accept-Language': 'en-us;q=0.5,en;q=0.3',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
'Host':'202.115.133.173:805',
'Referer':'',
'Upgrade-Insecure-Requests':'1',
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'
}
def treatpwd(user, sign, pwd):
pwdmd5 = hashlib.md5()
pwdmd5.update(pwd.encode("utf-8"))
loginpwd = pwdmd5.hexdigest()
return loginpwd
datas = {
'Action':'Login',
'userName':username,
'pwd':treatpwd(username, sign, password),
'sign':sign,
}
if name == "__main__":
req = requests.Session()
headers['Referer'] = url1
print(headers)
req.headers.update(headers)
resp1 = req.post(url1,data=datas)
print(resp1)
headers['Referer'] = url1
print(headers)
req.headers.update(headers)
print(req.headers)
resp2 = req.get(url2)
print(resp2.headers)
headers['Referer'] = url2
req.headers.update(headers)
resp3 = req.get(url3)
print(resp3.headers)
print(resp3)
我在网上查询了之后,发现可能是refer的问题,但是更新refer的时候又出了问题。
以下是输出信息:
{'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8', 'Accept-Encoding': 'gzip, deflate, compress', 'Accept-Language': 'en-us;q=0.5,en;q=0.3', 'Cache-Control': 'max-age=0', 'Connection': 'keep-alive', 'Host': '202.115.133.173:805', 'Referer': 'http://202.115.133.173:805/Common/Handler/UserLogin.ashx', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'}
{'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8', 'Accept-Encoding': 'gzip, deflate, compress', 'Accept-Language': 'en-us;q=0.5,en;q=0.3', 'Cache-Control': 'max-age=0', 'Connection': 'keep-alive', 'Host': '202.115.133.173:805', 'Referer': 'http://202.115.133.173:805/Common/Handler/UserLogin.ashx', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'}
{'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0', 'Accept-Encoding': 'gzip, deflate, compress', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8', 'Connection': 'keep-alive', 'Accept-Language': 'en-us;q=0.5,en;q=0.3', 'Cache-Control': 'max-age=0', 'Host': '202.115.133.173:805', 'Referer': 'http://202.115.133.173:805/Common/Handler/UserLogin.ashx', 'Upgrade-Insecure-Requests': '1'}
{'Content-Type': 'text/html', 'Content-Encoding': 'gzip', 'Last-Modified': 'Thu, 23 Nov 2017 03:09:08 GMT', 'Accept-Ranges': 'bytes', 'ETag': '"0a24a6d864d31:0"', 'Vary': 'Accept-Encoding', 'Server': 'Microsoft-IIS/7.5', 'X-Powered-By': 'ASP.NET', 'Date': 'Sat, 07 Apr 2018 13:19:10 GMT', 'Content-Length': '1329'}
{'Cache-Control': 'private', 'Content-Type': 'text/html; charset=utf-8', 'Server': 'Microsoft-IIS/7.5', 'X-AspNet-Version': '4.0.30319', 'X-Powered-By': 'ASP.NET', 'Date': 'Sat, 07 Apr 2018 13:19:11 GMT', 'Content-Length': '4179'}
Process finished with exit code 0
现在感觉有点晕,不知道应该怎么做了。
顺带一提:我输出登陆成功后的respons的源码时,发现也是不对,说明在登陆成功的页面就出了问题。
python asp.net requests_python3使用requests访问asp页面时出错,返回500相关推荐
- python爬虫实践记录-基于requests访问翻译网页爬取结果
前言 目前主流的翻译网站反爬虫都挺严格的,某度有sign算法,谷歌自带技能冷却.... 查了一下发现一个反爬虫没用那么苛刻的翻译网站:译典通. 第一次听说这个网站,界面挺老,爬来的源代 ...
- python如何下载安装spacy_使用pip安装Spacy时出错
它可能与虚拟环境(venv)中安装的其他python包发生冲突.我就是这样.我尝试将pip安装到已经安装了以下软件包的venv中:appnope==0.1.0 beautifulsoup4==4.5. ...
- ubuntu安装python编译器_在Ubuntu上安装/编译grpc时出错
我有protobuf编译器版本3.0,需要安装grpc和grpc python插件.在教程之后,我将deb http://http.debian.net/debian jessie-backports ...
- python安装numba_python – 在OS X上安装Numba时出错
我无法在我的OS X系统上安装Numba(通过pip). 我在用着 > Python:2.7.11(Homebrew) pip:8.1.1 > setuptools:20.6.7 > ...
- python安装opencv出现错误,通过pip安装opencv时出错
python version = Python 3.8.0 pip version = 19.3.1 C:\Users\Sami Ullah Ch>pip3 install opencv-pyt ...
- Nginx设置访问Web页面时用户名密码验证
1.可能存在的需求 网页不想让所有人访问到,只让知道页面密码的人可以打开 某些组件的web端管理页面无用户名密码认证可直接打开,添加一个用户验证 ES如果不添加search-guard,是否有别的更简 ...
- vue-router next(false) 禁止访问某个页面时,不保留历史访问记录
用户正常访问流程为 产品列表页面[a页面]->产品详情页面(选择不同的计划价格因素后点击购买)[b页面]->产品购买页面[c页面] 下面进行如下操作: c页面 按 <- 返回键 返回 ...
- python双引号打不出来_在python 3中使用单引号和双引号时出错 - python
使用os.system()函数时,我在python中遇到了EOL错误. 以下是代码行生成错误: os.system("cat subdomains.txt | cut -d'"' ...
- jasp报错_jetty启动访问jsp页面报错
jfinal3.5,jfinal jetty-server 2018.11,然后引入了apache-jsp和apache-jstl,访问jsp页面时还是提示org.apache.jasper.Jasp ...
最新文章
- 数据挖掘导论读书笔记5关联分析的基本概念和算法
- cron计划任务使用
- python psycopg2_Ubuntu 安装 PostgreSQL 和 python-psycopg2基础教程(以及错误解决)
- Linux文件基本属性
- matlab积分与绘图
- .net项目开发工具(v2.0)功能完善专帖
- linux C语言之called object ‘maze’ is not a function or function pointer printf(“%d\t“, maze(i, j))
- leetcode 228. 汇总区间
- selenium 验证码——万能码的使用
- flowable6.4.2流程审批后涉及到的表
- Epos消费管理系统复制迁移SQL SERVER 2005数据库
- 手机900e模式如何救_手机护眼模式真的有用吗?长时间看手机如何保护视力?...
- Linux电源管理-概述
- VUE小需求——旋转小图标
- 计算机中堆栈指针的作用,堆栈指针是什么_有什么作用
- python视频补帧_我花了三天写了手机补帧神器
- QT5在arm板上的汉字显示
- 机器学习之朴素贝叶斯、贝叶斯信念网络
- 《wireshark》怎么抓包
- F - Shifting String(置换的阶+思维)
热门文章
- html字符串使用xpath,使用XPath和regex在HTML注释中提取文本
- mac 上安装Homebrew
- 离散实验偏序关系满足实验报告C语言,离散数学实验三:偏序关系中盖住关系的求取及格论中有补格的判定...
- 如何获取58上真实号码_如何获取Apollo上项目下的所有namespace?
- 【转】python-word2vec模块使用详解
- elasticsearch 根据条件更新数据
- Premiere Pro CC2017教程(二) 修改导入静态图片的时间
- Linux nc命令
- mysql5.7开启远程连接
- 又一个4000字肝货,详解tkinter图形化界面制作流程!