post get 请求 headers注释哪些

  1. post和get
    #post请求
    fomdata=urllib.parse.urlencode(fomdata).encode() request=urllib.request.Request(url=url,headers=headers) response=urllib.request.urlopen(request,fomdata) print(response.read().decode()) #get请求 formdata=urllib.parse.urlencode(formdata) url=url+formdata request=urllib.request.Request(url=url,headers=headers) response=urllib.request.urlopen(request) print(response.read().decode())
  2. headers
    headers={
    # ':authority': 'fanyi.baidu.com',
    # ':method':'POST' ,
    # ':path': '/v2transapi',
    # ':scheme': 'https',
    # 'accept':' */*',
    # 'accept-encoding': 'gzip, deflate, br',
    'accept-language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7',
    # content-length: 120
    'content-type':'application/x-www-form-urlencoded; charset=UTF-8',
    'cookie': 'BIDUPSID=344E96ED3E73C19886D2399AFC06F786; PSTM=1569325908; BDRCVFR[PaHiFN6tims]=9xWipS8B-FspA7EnHc1QhPEUf; delPer=0; H_PS_PSSID=; BAIDUID=7010B62BC424CB7AA40287983B9D0215:FG=1; to_lang_often=%5B%7B%22value%22%3A%22en%22%2C%22text%22%3A%22%u82F1%u8BED%22%7D%2C%7B%22value%22%3A%22zh%22%2C%22text%22%3A%22%u4E2D%u6587%22%7D%5D; REALTIME_TRANS_SWITCH=1; FANYI_WORD_SWITCH=1; HISTORY_SWITCH=1; SOUND_SPD_SWITCH=1; SOUND_PREFER_SWITCH=1; locale=zh; from_lang_often=%5B%7B%22value%22%3A%22zh%22%2C%22text%22%3A%22%u4E2D%u6587%22%7D%2C%7B%22value%22%3A%22en%22%2C%22text%22%3A%22%u82F1%u8BED%22%7D%5D; BDRCVFR[L_O2j-KLwCb]=9xWipS8B-FspA7EnHc1QhPEUf; PSINO=7; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1569325935,1569325981,1569326164,1569327273; Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1569327273; __yjsv5_shitong=1.0_7_2ba691681ef2bf8fe83cac2ac05d6d7b920e_300_1569327272977_120.192.27.116_b8b27433; yjs_js_security_passport=597fd813e841914fb2438ff168e087a634ead1a1_1569327273_js',
    'origin': 'https://fanyi.baidu.com',
    'referer': 'https://fanyi.baidu.com/?aldtype=16047',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36',
    # 'x-requested-with': 'XMLHttpRequest',
    }
原文地址:https://www.cnblogs.com/ybl20000418/p/11581280.html