fiddler and python post request notes

python3

1.fiddler capture, if textview string for a string, as shown below:

Then we construct the data, shall be in the following format:

    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. If the post json data format, as shown below:

 

 Since the data is the POST json format required json.dumps (post_data) post_data converted to a string, before encoding

     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)

 

Published 24 original articles · won praise 30 · views 50000 +

Guess you like

Origin blog.csdn.net/yufen9987/article/details/102795003