如何用python requests post一段字符串
我要post一段数据,正确的浏览器post数据如下
POST /boss/gridturnpage?action=refresh&pk=-1&condition=custCode%3D%26businessId%3D-1%26beginlogDate%3D2015-04-20%26endlogDate%3D2015-04-20%26opId%3D%26orgId%3D&tmpPercentWidth=1028&localcache=table&url_source=XMLHTTP HTTP/1.1
Accept: */*
Content-Type: multipart/form-data
Referer: http://10.81.0.3:8080/boss/boss/so/soinfomgr/QryOrdSoRecord.jsp
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; InfoPath.3; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729)
Host: 10.81.0.3:8080
Content-Length: 1255
DNT: 1
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: USERINFO_ATTR=AppframeSerial_12959; CRM_WEB=MJmjV0yh1nzRTVJNTnT1ZTF3mjpLTwGLnkL9wxzy1Fjkk6p5GKGP!-257094400
<TableInfo
tableid="tblOffer" setname="com.asiainfo.boss.common.web.solog.SETOrdHistory" tablemodel="com.ai.appframe2.web.datamodel.MethodModelForService" implservice_name="com.asiainfo.boss.so.order.base.service.interfaces.IBusiOrderQuerySV" implservice_querymethod="getQOrdSoLogValues(String custCode,long businessId,String beginlogDate,String endlogDate,String opId,String orgId,int $STARTROWINDEX, int $ENDROWINDEX)" implservice_countmethod="getQOrdSoLogValuesCount(String custCode,long businessId,String beginlogDate,String endlogDate,String opId,String orgId)"
multiselect="false" isquerycount="TRUE" rowsequence="true" width="100%" height="180" pagesize="50" >
<col fieldname='PROD_SPEC_ID' visible='false' />
<col fieldname='SRC_TYPE' visible='false' />
<col fieldname="BUSI_ID" />
<col fieldname="ORD_CUST_ID" />
<col fieldname="BUSI_TYPE" />
<col fieldname="DONE_DATE" width="150" />
<col fieldname="CUST_NAME" width="80" />
<col fieldname="CUST_CODE" title="............" />
<col fieldname="OP_ID" width="80" />
<col fieldname="CURRENT_ORG_ID" width="120" title="............" />
<col fieldname="PAY_STATE" width="80" />
<col fieldname="APP_STATE" width="80" />
<col fieldname="REMARK" width="150" />
</TableInfo>
下面是我的代码,boss.txt内容就是<TableInfo 开始到结束,返回的是500
headers2={"Content-Type":"multipart/form-data",
"Referer":"http://10.81.0.3:8080/boss/boss/so/soinfomgr/QryOrdSoRecord.jsp",
"Accept-Language":"zh-cn",
"Accept-Encoding":"gzip, deflate",
"DNT":"1"}
s.headers.update(headers2)
files = {'':('',open(r'f:\boss.txt', 'rb'))}
files== urllib.parse.urlencode(files).encode(encoding="gbk")
r=s.post(url='http://10.81.0.3:8080/boss/gridturnpage?action=refresh&pk=-1&condition=custCode%3D%26businessId%3D-1%26beginlogDate%3D2015-04-16%26endlogDate%3D2015-04-17%26opId%3D%26orgId%3D&tmpPercentWidth=1011&localcache=table&url_source=XMLHTTP',files=files)
下面我post的抓包,怎样才能将数据正确的post上去?
我擦嘞闹得住菇
10 years, 8 months ago