python POST请求成功但返回error.jsp?
本人初学python,模拟登陆公司内网抓取数据.
我的代码和结果如下:
>>> import requests
>>> url = "https://168.7.7.71:9000/CMIS/servlet/dataengine"
>>> data = {"id":"Command_Query","action":"com~2eABC~2ecmis~2eafterloanmanage~2ecreditlnemanage~2eweb~2eSingleCustomerCreditLimitAction","method":"queryData","datasets":[{"id":"Dataset_CreditLimitInfo","pageNo":1,"pageSize":15,"calculateTotalSize":True,"fields":[{"name":"creditserialno","label":"^989d^5ea6^6d41^6c34^53f7","maxLength":40,"dataType":"string"},{"name":"customerno","label":"^5ba2^6237^6807^8bc6^53f7","maxLength":40,"dataType":"string"},{"name":"customername","label":"^5ba2^6237^540d^79f0","maxLength":80,"dataType":"string"},{"name":"customertype","label":"^5ba2^6237^7c7b^578b","maxLength":40,"dataType":"string"},{"name":"customertypename","label":"^5ba2^6237^7c7b^578b","maxLength":40,"dataType":"string"},{"name":"opinionserialno","label":"^901a^77e5^4e66^6d41^6c34^53f7","maxLength":20,"dataType":"string"},{"name":"credittype","label":"^989d^5ea6^7c7b^578b","maxLength":20,"dataType":"string"},{"name":"credittypename","label":"^989d^5ea6^7c7b^578b","maxLength":80,"dataType":"string"},{"name":"creditcycle","label":"^662f^5426^5faa^73af","maxLength":40,"dataType":"string"},{"name":"creditcyclename","label":"^662f^5426^5faa^73af","maxLength":40,"dataType":"string"},{"name":"efforgid","label":"^989d^5ea6^9002^7528^673a^6784","maxLength":40,"dataType":"string"},{"name":"efforgidname","label":"^989d^5ea6^9002^7528^673a^6784","maxLength":80,"dataType":"string"},{"name":"approveorg","label":"^989d^5ea6^6279^51c6^673a^6784","maxLength":40,"dataType":"string"},{"name":"approveorgname","label":"^989d^5ea6^6279^51c6^673a^6784","maxLength":200,"dataType":"string"},{"name":"currency","label":"^5e01^79cd","maxLength":20,"dataType":"string"},{"name":"currencyname","label":"^5e01^79cd","maxLength":20,"dataType":"string"},{"name":"exposuresum","label":"^655e^53e3^91d1^989d","maxLength":24,"dataType":"bigdecimal"},{"name":"enddate","label":"^5230^671f^65e5^671f","maxLength":10,"dataType":"string"},{"name":"exposurebal","label":"^655e^53e3^4f59^989d","maxLength":24,"dataType":"bigdecimal"},{"name":"residuesum","label":"^53ef^7528^655e^53e3^91d1^989d","maxLength":24,"dataType":"bigdecimal"},{"name":"creditsum","label":"^6388^4fe1^91d1^989d","maxLength":24,"dataType":"bigdecimal"},{"name":"residuecreditbal","label":"^6388^4fe1^4f59^989d","maxLength":24,"dataType":"bigdecimal"},{"name":"residuecreditsum","label":"^53ef^7528^6388^4fe1^91d1^989d","maxLength":24,"dataType":"bigdecimal"},{"name":"status","label":"^989d^5ea6^72b6^6001","maxLength":20,"dataType":"string"},{"name":"statusname","label":"^989d^5ea6^72b6^6001","maxLength":20,"dataType":"string"},{"name":"origintype","label":"^6570^636e^6765^6e90^7c7b^578b","maxLength":4,"dataType":"string"},{"name":"origintypename","label":"^6570^636e^6765^6e90^7c7b^578b","maxLength":20,"dataType":"string"},{"name":"isunioncredit","label":"^662f^5426^8054^8d37^8054^4fdd^989d^5ea6","maxLength":20,"dataType":"string"},{"name":"isunioncreditname","label":"^662f^5426^8054^8d37^8054^4fdd^989d^5ea6","maxLength":20,"dataType":"string"},{"name":"islink","label":"^662f^5426^4e32^7528","maxLength":20,"dataType":"string"},{"name":"islinkname","label":"^662f^5426^4e32^7528","maxLength":20,"dataType":"string"},{"name":"inputuser","label":"^767b^8bb0^4eba","maxLength":40,"dataType":"string"},{"name":"inputusername","label":"^767b^8bb0^4eba","maxLength":40,"dataType":"string"},{"name":"inputorg","label":"^767b^8bb0^673a^6784","maxLength":40,"dataType":"string"},{"name":"inputorgname","label":"^767b^8bb0^673a^6784","maxLength":200,"dataType":"string"},{"name":"inputtime","label":"^767b^8bb0^65e5^671f","maxLength":20,"dataType":"string"}]}],"submitForm":{"elements":[{"id":"Text_customerno","value":"","text":""},{"id":"Param_customerno","value":"","text":""},{"id":"Text_customername","value":"","text":""},{"id":"Param_customername","value":"","text":""},{"id":"Param_iscustomername","value":"","text":""},{"id":"Text_credittype","value":"","text":""},{"id":"Param_credittype","value":"","text":""},{"id":"Text_status","value":"02","text":"^751f^6548"},{"id":"Param_status","value":"02","text":"02"},{"id":"Text_creditserialno","value":"ed201704120819","text":"ed201704120819"},{"id":"Param_creditserialno","value":"ed201704120819","text":"ed201704120819"},{"id":"Text_efforgid","value":"","text":""},{"id":"Param_efforgid","value":"","text":""},{"id":"Param_isefforgid","value":"","text":""},{"id":"Text_opinionserialno","value":"","text":""},{"id":"Param_opinionserialno","value":"","text":""},{"id":"Text_islink","value":"","text":""},{"id":"Param_islink","value":"","text":""},{"id":"efforgid","value":"","text":""},{"id":"Text_customertype","value":"","text":""},{"id":"Param_customertype","value":"01","text":"01"},{"id":"sCusType","value":"^5f53^524d^5ba2^6237^7c7b^578b","text":"^5f53^524d^5ba2^6237^7c7b^578b"},{"id":"Param_sCusType","value":"01","text":"01"}]}}
>>> r = requests.post(url,data=data,verify=False)
>>> print(r.content)
b'{ isSuccess:true, messageType:0, forward:{id:"index",target:"_self",path:"/error.jsp"} } '
>>> print(r.status_code)
200
我用HttpWatch抓取的成功提交查询request如下:
POST /CMIS/servlet/dataengine HTTP/1.1
Accept: */*
Accept-Language: zh-CN
Referer: https://168.7.7.71:9000/CMIS/jsp/AfterLoanManage/CreditLineManage/singlecustomercreditlimit.jsp
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.2; Tablet PC 2.0)
Host: 168.7.7.71:9000
Content-Length: 4395
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: JSESSIONIDCMIS=MyqgZrzfWrjHG81yJHt4psfhspFXlWH0DQrX2CjWdlNqR1JtPn83!1665640186
{id:"Command_Query",action:"com~2eABC~2ecmis~2eafterloanmanage~2ecreditlnemanage~2eweb~2eSingleCustomerCreditLimitAction",method:"queryData",datasets:[{id:"Dataset_CreditLimitInfo",pageNo:1,pageSize:53908,calculateTotalSize:true,fields:[{name:"creditserialno",label:"^989d^5ea6^6d41^6c34^53f7",maxLength:40,dataType:"string"},{name:"customerno",label:"^5ba2^6237^6807^8bc6^53f7",maxLength:40,dataType:"string"},{name:"customername",label:"^5ba2^6237^540d^79f0",maxLength:80,dataType:"string"},{name:"customertype",label:"^5ba2^6237^7c7b^578b",maxLength:40,dataType:"string"},{name:"customertypename",label:"^5ba2^6237^7c7b^578b",maxLength:40,dataType:"string"},{name:"opinionserialno",label:"^901a^77e5^4e66^6d41^6c34^53f7",maxLength:20,dataType:"string"},{name:"credittype",label:"^989d^5ea6^7c7b^578b",maxLength:20,dataType:"string"},{name:"credittypename",label:"^989d^5ea6^7c7b^578b",maxLength:80,dataType:"string"},{name:"creditcycle",label:"^662f^5426^5faa^73af",maxLength:40,dataType:"string"},{name:"creditcyclename",label:"^662f^5426^5faa^73af",maxLength:40,dataType:"string"},{name:"efforgid",label:"^989d^5ea6^9002^7528^673a^6784",maxLength:40,dataType:"string"},{name:"efforgidname",label:"^989d^5ea6^9002^7528^673a^6784",maxLength:80,dataType:"string"},{name:"approveorg",label:"^989d^5ea6^6279^51c6^673a^6784",maxLength:40,dataType:"string"},{name:"approveorgname",label:"^989d^5ea6^6279^51c6^673a^6784",maxLength:200,dataType:"string"},{name:"currency",label:"^5e01^79cd",maxLength:20,dataType:"string"},{name:"currencyname",label:"^5e01^79cd",maxLength:20,dataType:"string"},{name:"exposuresum",label:"^655e^53e3^91d1^989d",maxLength:24,dataType:"bigdecimal"},{name:"enddate",label:"^5230^671f^65e5^671f",maxLength:10,dataType:"string"},{name:"exposurebal",label:"^655e^53e3^4f59^989d",maxLength:24,dataType:"bigdecimal"},{name:"residuesum",label:"^53ef^7528^655e^53e3^91d1^989d",maxLength:24,dataType:"bigdecimal"},{name:"creditsum",label:"^6388^4fe1^91d1^989d",maxLength:24,dataType:"bigdecimal"},{name:"residuecreditbal",label:"^6388^4fe1^4f59^989d",maxLength:24,dataType:"bigdecimal"},{name:"residuecreditsum",label:"^53ef^7528^6388^4fe1^91d1^989d",maxLength:24,dataType:"bigdecimal"},{name:"status",label:"^989d^5ea6^72b6^6001",maxLength:20,dataType:"string"},{name:"statusname",label:"^989d^5ea6^72b6^6001",maxLength:20,dataType:"string"},{name:"origintype",label:"^6570^636e^6765^6e90^7c7b^578b",maxLength:4,dataType:"string"},{name:"origintypename",label:"^6570^636e^6765^6e90^7c7b^578b",maxLength:20,dataType:"string"},{name:"isunioncredit",label:"^662f^5426^8054^8d37^8054^4fdd^989d^5ea6",maxLength:20,dataType:"string"},{name:"isunioncreditname",label:"^662f^5426^8054^8d37^8054^4fdd^989d^5ea6",maxLength:20,dataType:"string"},{name:"islink",label:"^662f^5426^4e32^7528",maxLength:20,dataType:"string"},{name:"islinkname",label:"^662f^5426^4e32^7528",maxLength:20,dataType:"string"},{name:"inputuser",label:"^767b^8bb0^4eba",maxLength:40,dataType:"string"},{name:"inputusername",label:"^767b^8bb0^4eba",maxLength:40,dataType:"string"},{name:"inputorg",label:"^767b^8bb0^673a^6784",maxLength:40,dataType:"string"},{name:"inputorgname",label:"^767b^8bb0^673a^6784",maxLength:200,dataType:"string"},{name:"inputtime",label:"^767b^8bb0^65e5^671f",maxLength:20,dataType:"string"}]}],submitForm:{elements:[{id:"Text_customerno",value:"",text:""},{id:"Param_customerno",value:"",text:""},{id:"Text_customername",value:"",text:""},{id:"Param_customername",value:"",text:""},{id:"Param_iscustomername",value:"",text:""},{id:"Text_credittype",value:"",text:""},{id:"Param_credittype",value:"",text:""},{id:"Text_status",value:"02",text:"^751f^6548"},{id:"Param_status",value:"02",text:"02"},{id:"Text_creditserialno",value:"ed201704120819",text:"ed201704120819"},{id:"Param_creditserialno",value:"ed201704120819",text:"ed201704120819"},{id:"Text_efforgid",value:"",text:""},{id:"Param_efforgid",value:"",text:""},{id:"Param_isefforgid",value:"",text:""},{id:"Text_opinionserialno",value:"",text:""},{id:"Param_opinionserialno",value:"",text:""},{id:"Text_islink",value:"",text:""},{id:"Param_islink",value:"",text:""},{id:"efforgid",value:"",text:""},{id:"Text_customertype",value:"",text:""},{id:"Param_customertype",value:"01",text:"01"},{id:"sCusType",value:"^5f53^524d^5ba2^6237^7c7b^578b",text:"^5f53^524d^5ba2^6237^7c7b^578b"},{id:"Param_sCusType",value:"01",text:"01"}]}}
返回的response如下:
HTTP/1.0 200 OK
Date: Mon, 29 May 2017 11:28:25 GMT
Server: Apache/2.2.19 (Unix) mod_ssl/2.2.19 OpenSSL/1.0.0d
Content-Length: 965
X-Powered-By: Servlet/2.4 JSP/2.0
Connection: close
Content-Type: text/html;charset=GBK
{"messageType":0,"parameters":[],"isSuccess":true,"datasets":[{"filter":"","records":[{"isCurrent":false,"newDatas":["ed201704120819","CC100004094000","^4e00^62d6^ff08^59dc^5830^ff09^52a8^529b^673a^68b0^6709^9650^516c^53f8","01","^5bf9^516c^5ba2^6237","tz201704120854","301","301~20~2d~2d^94f6^884c^627f^5151^6c47^7968","02","^5426","G0011483","^5357^4eac^6cf0^5dde^5206^884c^4f01^4e1a^91d1^878d^4e1a^52a1^4e09^90e8","G0011489","^5357^4eac^6cf0^5dde^5206^884c^884c^957f^5ba4","01","01~2d~2d^4eba^6c11^5e01","0","2017~2f10~2f12","0","0","10500000","10500000","0","02","^751f^6548","01","^901a^77e5^4e66^751f^6210","02","^5426","01","^662f","U000038265","^5f20^7ade","G0000642","^5357^4eac^6cf0^5dde^5206^884c","2017~2f04~2f12"],"state":0,"isSelected":false}],"totalSize":1,"parameters":[],"pageSize":53908,"pageNo":1,"pageCount":1,"id":"Dataset_CreditLimitInfo"}],"forward":{"contextRelative":true,"target":"","path":"","id":""},"messageText":"^64cd^4f5c^6210^529f"}
请教各位大神为什么链接成功了但得不到数据,应该怎样修改?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
服务器发现了不合法的请求,被重定向了。