zoukankan      html  css  js  c++  java
  • 使用requests模块post payload请求

    import json
    import requests
    import datetime
    
    postUrl = 'https://sellercentral.amazon.com/fba/profitabilitycalculator/getafnfee?profitcalcToken=en2kXFaY81m513NydhTZ9sdb6hoj3D'
    # payloadData数据
    payloadData = {
    'afnPriceStr': 10,
    'currency':'USD',
    'productInfoMapping': {
    'asin': 'B072JW3Z6L',
    'dimensionUnit': 'inches',
    }
    }
    # 请求头设置
    payloadHeader = {
    'Host': 'sellercentral.amazon.com',
    'Content-Type': 'application/json',
    }
    # 下载超时
    timeOut = 25
    # 代理
    proxy = "183.12.50.118:8080"
    proxies = {
    "http": proxy,
    "https": proxy,
    }
    r = requests.post(postUrl, data=json.dumps(payloadData), headers=payloadHeader)
    dumpJsonData = json.dumps(payloadData)
    print(f"dumpJsonData = {dumpJsonData}")
    res = requests.post(postUrl, data=dumpJsonData, headers=payloadHeader, timeout=timeOut, proxies=proxies, allow_redirects=True)
    # 下面这种直接填充json参数的方式也OK
    # res = requests.post(postUrl, json=payloadData, headers=header)
    print(f"responseTime = {datetime.datetime.now()}, statusCode = {res.status_code}, res text = {res.text}")
  • 相关阅读:
    202011.19
    202011.18
    202011.17
    202011.16
    202011.14
    jdk的下载和配置
    layui中form表单
    JS中utocomplete
    转:JqueryUI学习笔记-自动完成autocomplete
    JSON.parse()与JSON.stringify()的区别
  • 原文地址:https://www.cnblogs.com/hankleo/p/10477502.html
Copyright © 2011-2022 走看看