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}")

使用requests模块post payload请求的更多相关文章

  1. Python接口测试-使用requests模块发送GET请求

    本篇主要记录下使用python的requests模块发送GET请求的实现代码. 向服务器发送get请求:无参数时:r = requests.get(url)带params时:r = requests. ...

  2. Python接口测试-使用requests模块发送post请求

    本篇主要记录下使用python的requests模块发送post请求的实现代码. #coding=utf-8 import unittest import requests class PostTes ...

  3. python 爬虫 基于requests模块的get请求

    需求:爬取搜狗首页的页面数据 import requests # 1.指定url url = 'https://www.sogou.com/' # 2.发起get请求:get方法会返回请求成功的响应对 ...

  4. 基于python第三方requests 模块的HTTP请求类

    使用requests模块构造的下载器,首先安装第三方库requests pip install requests 1 class StrongDownload(object): def __init_ ...

  5. python - 怎样使用 requests 模块发送http请求

    最近在学python自动化,怎样用python发起一个http请求呢? 通过了解 request 模块可以帮助我们发起http请求 步骤: 1.首先import 下 request 模块 2.然后看请 ...

  6. requests模块发送POST请求

    在HTTP协议中,post提交的数据必须放在消息主体中,但是协议中并没有规定必须使用什么编码方式,从而导致了 提交方式 的不同.服务端根据请求头中的 Content-Type 字段来获知请求中的消息主 ...

  7. python中Requests模块中https请求在设置为忽略有效性验证,屏蔽告警信息的方式

    增加下面的就ok了from requests.packages.urllib3.exceptions import InsecureRequestWarningrequests.packages.ur ...

  8. [实战演练]python3使用requests模块爬取页面内容

    本文摘要: 1.安装pip 2.安装requests模块 3.安装beautifulsoup4 4.requests模块浅析 + 发送请求 + 传递URL参数 + 响应内容 + 获取网页编码 + 获取 ...

  9. 01: requests模块

    目录: 1.1 requests模块简介 1.2 使用requests模块发送get请求 1.3 使用requests模块发送post请求 1.4 requests.request()参数介绍 1.1 ...

随机推荐

  1. 学习实践之DEMO《nodejs模拟POST登陆》

    一个简单的PHP接收参数页面 <?php header("content-type:text/html;charset=utf-8"); if($_POST[username ...

  2. 牛刀小试MySQL--innodb_flush_log_at_trx_commit小结

    参数名:innodb_flush_log_at_trx_commit 参数值: 0 事务提交的时候,不会去刷日志缓存区,也不会立马写入至日志文件中.这种设置最危险.如果数据库挂了且运气不好,数据库的最 ...

  3. osgi.net框架简介

    osgi.net是一个动态的模块化框架.它向用户提供了模块化与插件化.面向服务构架和模块扩展支持等功能.该平台是OSGi联盟定义的服务平台规范移植到.NET的实现. 简介 尤埃开放服务平台是一个基于. ...

  4. 强烈推荐:240多个jQuery插件

    概述 jQuery 是继 prototype 之后又一个优秀的 Javascript 框架.其宗旨是—写更少的代码,做更多的事情.它是轻量级的 js 库(压缩后只有21k) ,这是其它的 js 库所不 ...

  5. WebFrom 【文件上传】

    文件上传 准备工作1.文件上传的页面2.上传文件要保存的文件夹 1.只要将文件传上来就行 //1.获取要上传的文件,并且知道要上传到服务器的路径 string s = "Uploads/aa ...

  6. C#日期转换(转载)

    转载来源:https://www.cnblogs.com/johnblogs/p/5912632.html DateTime.ToString()的各种日期格式 例: ToString:2016/9/ ...

  7. java - Jsoup原理

    https://blog.csdn.net/xh16319/article/details/28129845 http://www.voidcn.com/article/p-hphczsin-ru.h ...

  8. php中一个字符占用几个字节?

    先看看字符与字节有什么区别: (一)“字节”的定义 字节(Byte)是一种计量单位,表示数据量多少,它是计算机信息技术用于计量存储容量的一种计量单位. (二)“字符”的定义 字符是指计算机中使用的文字 ...

  9. HTML--Canvas基础入门

    一 HTML5画布基本介绍 1.HTML5专门为画布功能提供的标签:<canvas>,所以画布相关的功能都是基于这个标签来完成的; <canvas id="canvas&q ...

  10. Python 模块管理

    导入新的模块 创建一个 calculate.py 文件 print('ok') def add(x,y): return x + y def sub(x,y): return x - y 再创建一个 ...