python实现拼多多商品详情接口API

最近工作需要用到拼多多的一些接口,官方竟然没有提供,python的sdk,于是就自己简单的写了一个商品SKU接口的api。

1、代码

#!/usr/bin/python3# -*- coding: utf-8 -*-# @Time    : 2020/3/29 0021 下午 19:40# @Author  : xiaozhi!# @FileName: pdd_api# @Software: PyCharmimport timeimport hashlibimport requestsfrom urllib.parse import urlencode
class PddApi:    host = "https://gw-api.pinduoduo.com/api/router?"    headers = {        "accept": "application/json"    }
    def __init__(self, id=None, token=None, secret=None):        """        初始化        """        self.client_id = id        self.secret = secret        self.access_token = token        self.data_type = "JSON"
    def sign_md5(self, params):        """        对拼接好的字符串进行md5签名        """        hl = hashlib.md5()        hl.update(params.encode(encoding='utf-8'))        return hl.hexdigest().upper()
    def splice_str(self):        """        升序排序请求参数,连接字符串,并在首尾加上client_secret        """        self.timestamp = f"{time.time()}".split(".")[0]        pdd_dict = self.__dict__.copy()        secret = self.secret        del pdd_dict["secret"]        reverse_list = sorted([(k, str(v)) for k, v in pdd_dict.items()], key=lambda x:x[0])        reverse_list.insert(0, ("", secret))        reverse_list.append(("", secret))        reverse_list_str = list(map(lambda x: "".join(x), reverse_list))        params = "".join(reverse_list_str)        return params, pdd_dict
    def urlencode_data(self, params, pdd_dict):        pdd_dict["sign"] = self.sign_md5(params)        result = urlencode(pdd_dict)        url = f"{self.host}{result}"        return url
    def pdd_order_list_get(self, **kwargs):        """        获取订单列表        kwargs: order_status=None, refund_status=None, start_confirm_at=None, end_confirm_at=None,                           page=None, page_size=None        """        res_type = "pdd.order.list.get"        self.type = res_type        for k, v in kwargs.items():            setattr(self, k, v)        params, pdd_dict = self.splice_str()
        url = self.urlencode_data(params, pdd_dict)        return self.response_json(url=url)
    def pdd_order_information_get(self, order_sn=None):        """        获取订单详情        """        res_type = "pdd.order.information.get"        self.order_sn = order_sn        self.type = res_type        params, pdd_dict = self.splice_str()        url = self.urlencode_data(params, pdd_dict)        return self.response_json(url=url)
    def pdd_order_status_get(self, order_sns=None):        """        订单状态        """        res_type = "pdd.order.status.get"        self.order_sns = order_sns        self.type = res_type        params, pdd_dict = self.splice_str()        url = self.urlencode_data(params, pdd_dict)        return self.response_json(url=url)
    def pdd_erp_order_sync(self, **kwargs):        """        erp打单信息同步,        kwargs: order_sn=None, order_state=None, waybill_no=None, logistics_id=None        """        res_type = "pdd.erp.order.sync"        self.type = res_type        for k, v in kwargs.items():            setattr(self, k, v)        params, pdd_dict = self.splice_str()        url = self.urlencode_data(params, pdd_dict)        return self.response_json(url=url)
    def pdd_order_number_list_increment_get(self, **kwargs):        """        订单增量接口        kwargs: is_lucky_flag=None, order_state=None, start_updated_at=None, end_updated_at=None,page_size=None,        page=None, refund_status=None        """        res_type = "pdd.order.number.list.increment.get"        self.type = res_type        for k, v in kwargs.items():            setattr(self, k, v)        params, pdd_dict = self.splice_str()        url = self.urlencode_data(params, pdd_dict)        return self.response_json(url=url)
    def response_json(self, url):        res = requests.post(url=url, headers=self.headers)        return res.json()

2、调用:

图片

3、结果:

图片

返回值

{
	  "items": {
		"keyword": "女装",
		"page": "1",
		"real_total_results": 300,
		"total_results": 300,
		"list_count": 20,
		"item": [
			{
				"title": "【三件套】新款秋冬季女装套装裙皮草短外套搭打底衫毛衣配半身裙",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2020-06-05/b15035efb5913e1e8b647422010522c1.jpeg",
				"price": 134,
				"promotion_price": 134,
				"sales": 18000,
				"num_iid": 43992967514,
				"sample_id": "",
				"seller_nick": "果果家气质女装",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=43992967514"
			},
			{
				"title": "【2件套】套装秋冬新款仿獭兔毛钉珠皮草毛毛短外套加厚大衣女装",
				"pic_url": "https://omsproductionimg.yangkeduo.com/images/2018-06-06/463c0e2a5580ba3266846e41fe3e444a.jpeg",
				"price": 169,
				"promotion_price": 169,
				"sales": 40000,
				"num_iid": 1620002566,
				"sample_id": "",
				"seller_nick": "果果家气质女装",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=1620002566"
			},
			{
				"title": "仿水貂毛皮草外套女冬短款韩版修身显瘦百搭毛绒加厚新娘披肩礼服",
				"pic_url": "https://omsproductionimg.yangkeduo.com/images/2018-01-03/1f3866498a067e00e39a38fe144ec5f3.jpeg",
				"price": 88,
				"promotion_price": 88,
				"sales": 218,
				"num_iid": 410684172,
				"sample_id": "",
				"seller_nick": "乐荣源淘衣坊",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=410684172"
			},
			{
				"title": "仿貂毛大衣女秋冬加厚仿狐狸毛领皮草外套女长款仿水貂绒外套显瘦",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2020-06-28/f6ea981d0cfe5dc096af33457328c819.jpeg",
				"price": 298,
				"promotion_price": 298,
				"sales": 42000,
				"num_iid": 144592781204,
				"sample_id": "",
				"seller_nick": "珞摩服装旗舰店",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=144592781204"
			},
			{
				"title": "三件套裙套装新款秋冬女韩版钉珠皮草短外套搭打底衫毛衣配半身裙",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2020-09-24/1fd6806d8de95adce0196294765079f1.jpeg",
				"price": 269,
				"promotion_price": 269,
				"sales": 2525,
				"num_iid": 2748395485,
				"sample_id": "",
				"seller_nick": "蹦蹦服饰",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=2748395485"
			},
			{
				"title": "三件套2020新款秋冬季皮草裙套装女短外套搭打底衫毛衣配半身裙子",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2020-10-22/97440d8034ad1a319e71cd501aa6d9bc.jpeg",
				"price": 239,
				"promotion_price": 239,
				"sales": 119,
				"num_iid": 4544773413,
				"sample_id": "",
				"seller_nick": "自然之美服饰",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=4544773413"
			},
			{
				"title": "三件套裙套装2020新款秋冬季皮草女短外套搭打底衫毛衣配半身裙子",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2020-10-23/0e5aa1adb63ce256664d4274d0ff0fa1.jpeg",
				"price": 188,
				"promotion_price": 188,
				"sales": 1587,
				"num_iid": 3540607180,
				"sample_id": "",
				"seller_nick": "自然之美服饰",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=3540607180"
			},
			{
				"title": "2020秋冬装毛毛钉珠仿皮草外套新款韩版修身圆领学生上衣【单件】",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2021-01-28/503c10fe716873ceaccf103c30881908.jpeg",
				"price": 79,
				"promotion_price": 79,
				"sales": 1157,
				"num_iid": 35225305026,
				"sample_id": "",
				"seller_nick": "夏衣伊人",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=35225305026"
			},
			{
				"title": "两件套秋冬新款气质钉珠仿皮草外套配刺绣半身裙保暖加厚上衣女装",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2020-09-17/5d57e2f0df37b13f5472d03175246d28.jpeg",
				"price": 139,
				"promotion_price": 139,
				"sales": 2616,
				"num_iid": 369492636,
				"sample_id": "",
				"seller_nick": "蹦蹦服饰",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=369492636"
			},
			{
				"title": "2020秋冬装毛毛钉珠仿皮草外套新款韩版修身圆领淑女上衣【单件】",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2021-01-28/b208cc827f66c0b5eac9d40762178d28.jpeg",
				"price": 88,
				"promotion_price": 88,
				"sales": 232,
				"num_iid": 3540686169,
				"sample_id": "",
				"seller_nick": "自然之美服饰",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=3540686169"
			},
			{
				"title": "2018秋冬装毛毛钉珠仿皮草外套新款韩版修身圆领学生上衣【单件】",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2018-09-24/22c7a21f49c4ddfe228acc5d15c1bbe0.jpeg",
				"price": 138,
				"promotion_price": 138,
				"sales": 210,
				"num_iid": 3062555797,
				"sample_id": "",
				"seller_nick": "果果家气质女装",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=3062555797"
			},
			{
				"title": "三件套网红裙套装新款秋冬女钉珠皮草搭打底衫毛衣配半身裙短外套",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/images/2019-09-10/403fae6f0c281b247e305559cff71cca.jpeg",
				"price": 269,
				"promotion_price": 269,
				"sales": 144,
				"num_iid": 35224334938,
				"sample_id": "",
				"seller_nick": "夏衣伊人",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=35224334938"
			},
			{
				"title": "单件外套短款女秋冬新品海宁仿皮草韩版宽松显瘦百搭钉珠圆领上衣",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2020-09-24/55a25e3b612a5ba2655046718a20c0ab.jpeg",
				"price": 88,
				"promotion_price": 88,
				"sales": 2314,
				"num_iid": 368488818,
				"sample_id": "",
				"seller_nick": "蹦蹦服饰",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=368488818"
			},
			{
				"title": "粗花呢套装女2020秋冬新款小香风时尚洋气小西装包臀裙休身显瘦潮",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2020-07-16/84ffe1375b1d3b1a6455b9c387cd495b.jpeg",
				"price": 139,
				"promotion_price": 139,
				"sales": 216,
				"num_iid": 150435444702,
				"sample_id": "",
				"seller_nick": "小清新职装",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=150435444702"
			},
			{
				"title": "啄木鸟加厚羽绒棉衣女冬季新款胖mm宽松显瘦棉服外套女士大码棉袄",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2020-11-24/a8798a380a8e64503a3b6f2df3cdc5e6.jpeg",
				"price": 148,
				"promotion_price": 148,
				"sales": 2866,
				"num_iid": 203004819547,
				"sample_id": "",
				"seller_nick": "啄木鸟清晚田专卖店",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=203004819547"
			},
			{
				"title": "小香风套装裙女秋冬两件套裙子时尚气质贵夫人高档显瘦小西服上衣",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2020-09-20/11b73b78660ce240318981f36fedb20b.jpeg",
				"price": 106.8,
				"promotion_price": 106.8,
				"sales": 3585,
				"num_iid": 179099550022,
				"sample_id": "",
				"seller_nick": "蝶之语服饰",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=179099550022"
			},
			{
				"title": "粉色小西装春季新款名媛小香风套装裙两件套韩版时尚百搭收腰显瘦",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2020-03-17/2c08521a36bae37e004a5cfe15fcddb1.jpeg",
				"price": 119,
				"promotion_price": 119,
				"sales": 136,
				"num_iid": 94383041769,
				"sample_id": "",
				"seller_nick": "小清新职装",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=94383041769"
			},
			{
				"title": "小清新刺绣两件套套装裙兔毛领拼接短外套毛呢连衣裙秋冬甜美新款",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2019-10-07/6f734d1717a3339a74cff707d9ec82c0.jpeg",
				"price": 688,
				"promotion_price": 688,
				"sales": 3602,
				"num_iid": 50964999845,
				"sample_id": "",
				"seller_nick": "木木时尚服饰",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=50964999845"
			},
			{
				"title": "毛呢两件套装裙子女2021春秋季新款中长连衣裙修身妈妈装短款外套",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2020-03-12/d9b47beb0f7306f132216c910640f830.jpeg",
				"price": 89.8,
				"promotion_price": 89.8,
				"sales": 32000,
				"num_iid": 2713732007,
				"sample_id": "",
				"seller_nick": "露雪颜旗舰店",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=2713732007"
			},
			{
				"title": "白鸭绒2020冬季新款网红苏苏羽绒服女中长款大毛领收腰加厚外套潮",
				"pic_url": "https://t00img.yangkeduo.com/goods/images/2020-12-13/735fb9bd599594a424f3f22957aafd06.jpeg",
				"price": 299,
				"promotion_price": 299,
				"sales": 3292,
				"num_iid": 45642569064,
				"sample_id": "",
				"seller_nick": "晗晗羽绒厂家店",
				"post_fee": "",
				"area": "",
				"detail_url": "http://yangkeduo.com/goods.html?goods_id=45642569064"
			}
		]
	},

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/42086.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Flutter:EasyLoading(loading加载、消息提示)

前言 官方虽然提供了内置的加载指示器和提示信息,但是功能比较简陋,这里推荐:flutter_easyloading CircularProgressIndicator CircularProgressIndicator()加粗样式 ScaffoldMessenger.of(context).showSnackBar(const SnackBar(// 提示…

浅谈无人机遥感图像拼接与处理方法

遥感(RS-Remote Sensing)——不接触物体本身,用传感器收集目标物的电磁波信息,经处理、分析后,识别目标物,揭示其几何、物理性质和相互关系及其变化规律的现代科学技术。 换言之,即是“遥远的感…

第六章内存保护单元(Cortex-M7 Processor)

目录 第六章内存保护单元 6.1关于MPU 6.2MPU功能描述 6.3MPU编程器模型 第六章内存保护单元 介绍MPU (Memory Protection Unit)。它包含以下部分: 关于第6-2页的MPU。MPU功能描述见第6-3页。MPU程序员模型在第6-4页。 6.1关于MPU MPU是内存保护的可选组件。处理器支持标准…

从MVC跨越到DDD微服务架构是如何演进的

微服务架构演进 领域模型中对象的层次从内到外依次是:值对象、实体、聚合和限界上下文。 实体或值对象的简单变更,一般不会让领域模型和微服务发生大变。但聚合的重组或拆分却可以。因为聚合内业务功能内聚,能独立完成特定业务。那聚合的重组…

解决appium-doctor报ffmpeg cannot be found

一、下载ffmpeg安装包 https://ffmpeg.org/download.html 找到如图所示红框位置点击下载ffmpeg安装包。 二、配置ffmpeg环境变量 三、检查ffmpeg版本信息 重新管理员打开dos系统cmd命令提示符,输入ffmpeg查看是否出现版本信息,安装完好。 ffmpeg

D354周赛复盘:特殊元素平方和+数组最大美丽值(滑动窗口)+合法分割最小下标

文章目录 6889.特殊元素平方和思路完整版取模注意:不能对0取余/取模解答错误:本题的数组最后一个下标是nums[nums.size()] 6929.数组的最大美丽值(排序滑动窗口)思路1:排序滑动窗口注意点 6927. 合法分割的最小下标&am…

7.4Java EE——Bean的作用域

一、singleton作用域 Spring支持的5种作用域 作用域名城 描述 singleton 单例模式。在单例模式下,Spring 容器中只会存在一个共享的Bean实例, 所有对Bean的请求,只要请求的id(或name)与Bean的定义相匹配&#xff0…

css之flex两端对齐,且元素自动换行、flex、flow

文章目录 效果图htmlstyleflex-flow 效果图 html <div class"parent_element"><div class"item">7</div><div class"item">7</div><div class"item">7</div><div class"item"…

vue3 ts vite electron开发桌面程序

1、搭建vuetsvite项目 # 创建Vue项目 npm init vue # 安装依赖 npm install # 一定要安装成开发依赖 npm install electron electron-builder -D 根目录创建plugins文件夹&#xff0c;文件夹中创建ts文件&#xff0c;vite.electron.build.ts是打包文件代码&#xff0c;v…

spring复习:(22)实现了BeanNameAware等Aware接口的bean,相应的回调方法是在哪里被调用的?

AbstractAutowireCapableBeanFactory的doCreateBean用来创建bean, 其中调用了initializeBean方法对bean进行初始化 initializeBean包含如下代码&#xff1a; 而invokeAwareMethods代码如下&#xff1a; 可见其分别判断是否实现了BeanNameAware接口、BeanClassLoaderAware接口…

【java】【基础2】程序流程控制

目录 一、最经典的三种执行顺序 二、分支结构 2.1 if 2.2 switch 2.3 if与switch区别 三、循环结构 3.1 for循环 3.2 while循环 3.3 do-while循环 3.4 三种循环区别 3.5 补充知识&#xff1a;死循环 3.6 补充知识&#xff1a;循环嵌套 四、跳转关键字&#xff1a;br…

win7系统电脑怎么在桌面上悬挂工作日程安排清单显示呢?

在现代快节奏的工作环境中&#xff0c;合理安排和管理工作日程是非常重要的。而在电脑桌面上悬挂工作日程安排清单显示&#xff0c;可以让我们随时了解自己的任务和工作进度&#xff0c;提高工作效率。那么&#xff0c;如何在Win7系统电脑上实现这一功能呢&#xff1f; 今天我…

华为云ROMA Connect 的智能集成 – 现代企业数字化转型的新利器

在当今数字信息智能化的时代&#xff0c;人工智能技术逐渐深入企业的生产流程和实践中。人工智能的应用成为现代企业数字化转型的新利器。华为云的ROMA Connect作为企业级的融合集成服务 EiPaaS平台&#xff0c;从今年开始也进入了人工智能技术&#xff0c;针对几个主要的企业集…

selenium测试框架快速搭建(UI自动化测试)

一、介绍 selenium目前主流的web自动化测试框架&#xff1b;支持多种编程语言Java、pythan、go、js等&#xff1b;selenium 提供一系列的api 供我们使用&#xff0c;因此在web测试时我们要点页面中的某一个按钮&#xff0c;那么我们只需要获取页面&#xff0c;然后根据id或者na…

线程池学习(二)execute() 和 submit() 的区别

转载&#xff1a;线程池 线程提交的两种方式 ExecutorService poll3 Executors.newCachedThreadPool();for (int i 0; i < 2; i) {poll3.execute(new TargetTask());poll3.submit(new TargetTask());}execute方法 void execute(Runnable command): Executor接口中的方法s…

VSCode 注释后光标快速定位下一行

VSCode默认用 Ctrl / 注释一行时&#xff0c;光标停留在该行中。下面介绍如何注释后&#xff0c;光标会自动移动到下一行。 1.【View】 ->【Extensions】->【查找并安装Multi-command 扩展】 2.【File 】 -> 【Preferences 】->【Keyboard Shortcuts】&#xff08…

【数据结构】朴素模式匹配 KMP算法

&#x1f387;【数据结构】朴素模式匹配 & KMP 算法&#x1f387; &#x1f308; 自在飞花轻似梦,无边丝雨细如愁 &#x1f308; &#x1f31f; 正式开始学习数据结构啦~此专栏作为学习过程中的记录&#x1f31f; 文章目录 &#x1f387;【数据结构】朴素模式匹配 & K…

物理机传输大文件到虚拟机

物理机快速传输大文件到虚拟机 测试使用Tabby传输大文件到虚拟机 1.1 准备大文件 1.2 通过Tabby上传文件到Linux 总耗时约&#xff1a;7分钟 1.3 通过EveryThing配置服务 打开EveryThing&#xff0c;点击工具—> 选项—>http服务器 启用HTTP服务器&#xff0c;配置…

津津乐道设计模式 - 迭代器模式详解(以购物车的场景来演示迭代器模式)

&#x1f604; 19年之后由于某些原因断更了三年&#xff0c;23年重新扬帆起航&#xff0c;推出更多优质博文&#xff0c;希望大家多多支持&#xff5e; &#x1f337; 古之立大事者&#xff0c;不惟有超世之才&#xff0c;亦必有坚忍不拔之志 &#x1f390; 个人CSND主页——Mi…

前端 | (二)各种各样的常用标签 | 尚硅谷前端html+css零基础教程2023最新

学习来源&#xff1a;尚硅谷前端htmlcss零基础教程&#xff0c;2023最新前端开发html5css3视频 文章目录 &#x1f4da;HTML排版标签&#x1f4da;HTML语义化标签&#x1f4da;块级元素与行内元素&#x1f4da;文本标签&#x1f407;常用的文本标签&#x1f407;不常用的文本标…