python post有随机字符串_如何用python requests post一段字符串

我要post一段数据,正确的浏览器post数据如下

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31POST /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内容就是

1

2

3

4

5

6

7

8

9

10headers2={"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上去?

bVlszU

你是按照文件(multipart)的方式post上去对的,如果想把文件内容直接放在post的body里面,那么读一份文件的内容,然后放在data参数里面就行了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值