fiddler与python post请求笔记

python3

1.fiddler抓包,若textview中为一串字符串,如下图所示:

则我们构造的data,应为如下格式:

    from urllib import parse
    import urllib.request
    post_data =     {'flag':1,'BLC':0,'BLC_level':8,'light_restrain':1,'light_restrain_mode':0,'light_restrain_level0':8,
'light_restrain_level1':8,'PFR':50,'formatType':'P','MVR':0,'MHR':0,
'WDR':0,'WDR_level':8,'DDS':0,'DS':0,'defog_state':0,'defog_level':8,'Distortion_correction_mode':0,
'Distortion_correction_value':1}


    post_data = parse.urlencode(post_data).encode('utf-8')

    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36'
    }
    
    url = "http://*****"
    resp = urllib.request.Request(url= url,data = post_data , headers=headers)#post_data位json编码
    response = urllib2.urlopen(resp)

 2.若post数据为json格式,如下图所示 :

 

 由于POST的数据是json格式的,需要使用json.dumps(post_data)将post_data转换为字符串,再进行编码

     from urllib import parse
     import urllib.request
     post_data = {"SceneMode":scene_str,
    "BasicCMDConf":
    {"MVR_":0,"MHR_":0,"BLC_":0,"BLC_level_":8,"WDR_":0,
    "WDR_mode_":0,"WDR_level_":8,"light_restrain_":mode,
    "light_restrain_mode_":mode12,"light_restrain_level0_":level,
    "light_restrain_level1_":8,"DDS_":0,"DS_":0,
    "contrast_strength_":1,"defog_state_":0,"defog_level_":8,
    "Distortion_correction_mode":"0","Distortion_correction_value":"1"},
    "AEConf":{"AEMode_Select_":0,"Iris_select_":0,
    "IrisMode_ws":2,"Irislevel_ws":9,"Irisdeflevel_ws":99,
    "C2B_Switch_Select_":2,"IRC_Time_":20,"ICR_Sens_":0,"IR_light_":"null",
    "Fill_light_":0,"maxAE_Select_":48,"ShutterSpeed_":10,
    "startShutterSpeed_":15,"endShutterSpeed_":8,"AEGain_":1,
    "PowerMode_":0,"PowerValue_":99},
    "General":{"ImgBrightness_G_":78,"EdgeStrength_G_":128,
    "ImgHue_G_":128,"ImgContrast_G_":128,"ImgSaturation_G_":128,
    "ImgDenoise_G_":128},"WBConf":{"WBM_":0,"WBRG_":0,"WBBG_":0}}

    headers = {
     'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36'
    }
    
    url = "http://*****"

    resp = urllib.request.Request(url= url,data = json.dumps(post_data).encode('utf-8') , headers=headers)#post_data位json编码
    response = urllib.request.urlopen(resp)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值