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

news2024/11/24 11:11:31

最近工作需要用到拼多多的一些接口,官方竟然没有提供,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"
			}
		]
	},

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

docker基础1——架构组成、安装配置

文章目录 一、发展起源1.1 传统虚拟化与容器虚拟化1.2 docker底层核心技术1.2.1 命名空间1.2.2 控制组 1.3 docker工作方式1.4 docker容器编排1.5 docker优劣势1.6 docker架构组成 二、yum安装docker三、配置docker加速器 一、发展起源 背景了解: 容器是内核里的一项…

重磅升级 | 睿士主机威胁溯源系统全新升级,助力用户2023网络攻防演练

攻防演练至今已走过7个年头,逐渐成为网络安全防御体系中至关重要的一环。随着攻防演练对抗水平不断升级,攻击手段愈发隐蔽,攻击自动化程度逐步提高,技术储备也越来越有针对性,从广撒网到精准打击,这些都给蓝…

解决find: ‘/run/user/1000/gvfs’: 权限不够

问题描述 在用find查找对应的文件时,突然报错这个问题 解决办法 其实这个目录是空的,所以删除就好了执行下列操作: umount /run/user/1000/gvfs rm -rf /run/user/1000/gvfs 之后的查找中就没有了报错提示。

Spring AOP的介绍与实现

文章目录 Spring AOP1. Spring AOP概念2. Spring AOP的作用3.AOP的组成4. Spring AOP的实现4.1 添加Spring AOP依赖4.2 定义切面(创建切面类)4.3 定义切点(配置拦截规则)4.3.1 切点表达式语法 4.4 定义通知的实现 5. Spring AOP实…

【Java】Mybatis使用Collection属性

前言 这篇文章实现一下不使用left join等连接关键字来实现Mybatis的联表查询功能。包括json类型数据映射到Java实体类中。 库表 父表db1_json 子表db1_json_attach,子表parent_id对应副本的id。 实体类 新建Db1JsonDTO数据传递对象实体。 Data public class Db…

GRE实验

题目参考&#xff1a; 实验步骤&#xff1a; 第一步&#xff1a;地址规划拓扑设计&#xff0c;配置IP地址 R1配置&#xff1a; <Huawei>system-view [Huawei]sy R1 [R1]int g 0/0/1 [R1-GigabitEthernet0/0/1]ip address 192.168.1.1 24 [R1-GigabitEthernet0/0/1]in…

【JavaEE】JavaEE进阶:框架的学习 - Spring的初步认识

JavaEE进阶首章 文章目录 【JavaEE】JavaEE进阶&#xff1a;框架的学习 - Spring的初步认识1. JavaEE初阶 与 JavaEE进阶 开发上的区别1.1 Servlet VS Spring Boot1.2 Spring Boot的 “hello world”代码演示1.2.1 Spring Boot项目的创建1.2.2 hello world1.2.3 发布 2. 框架的…

Python补充笔记2-函数

目录 一、函数​编辑 二、函数的创建和调用​编辑 三、函数的参数传递​编辑 四、参数传递的内存分析​编辑 五、函数的返回值​编辑 六、函数的参数定义 默认值参数 七、函数的参数总结​编辑 八、变量的作用域​编辑 九、递归函数 十、斐波那契数列 十一、知识点总结​编辑 …

A7二极管-ASEMI迷你封装整流管A7二极管

编辑&#xff1a;ll A7二极管-ASEMI迷你封装整流管A7二极管 型号&#xff1a;A7二极管 品牌&#xff1a;ASEMI 封装&#xff1a;SOD-123 正向电流&#xff1a;1A 反向耐压&#xff1a;1000V 芯片大小&#xff1a;60MIL 芯片个数&#xff1a;1 引脚数量&#xff1a;2 …

将监控摄像头的监控视频放在网页或APP中无插件播放

需求 1)将监控摄像头的监控视频集成到网页中&#xff0c;实现无插件播放&#xff0c;监控摄像头可以是海康、大华、TPLink等 2)将监控视频集成到业务平台中播放&#xff0c;包括网页、微信公众号、小程序、APP等形态 3)远程调取内网里的摄像头视频&#xff0c;实现远程监控 实现…

git rebase 合并提交

一. 合并提交步骤 git log --oneline 查看当前提交记录 git rebase -i HEAD~2 选择最后提交的2条记录进行合并进入编辑界面,将c865404的pick改为f, 表示向前合并也就是向cc5a54合并 编辑完之后:wq 保存并退出git rebase --continuegit push --force origin feature/v1.2 推送…

12. 一些开发中遇到的SQL问题

文章目录 一些开发中遇到的SQL问题1. sql报11090错误,原因可能是以下错误&#xff0c;在&#xff1f;占位符后有一个空格2. 占位符&#xff1f;的位置不能是表名&#xff0c;否则会无法进行预编译3. mysql中desc是关键字&#xff0c;如果字段名称为desc会报错4. 数据库中时间格…

【已解决】天翼电信宽带改桥模式,使用路由器ppoe拨号

运营商在给办理宽带时会默认给宽带设置成光猫ppoe拨号&#xff0c;路由器只需设置为dhcp获取ip&#xff0c;插入到光猫的lan口即可上网。但运营商的光猫路由性能有限&#xff0c;会影响到网络体验。而将光猫设置为桥模式&#xff0c;使用路由器拨号&#xff0c;可以实现路由器进…

vue树组件循环表格

最近做项目需要实现循环表格这个需求&#xff0c;其中实用到了循环组件&#xff0c;特此记录一下&#xff0c;这是需要实现的功能&#xff0c;如下图&#xff1a; vue中实现组件循环 父组件 <template><div><ul><li v-for"(item,index) in aside…

Zabbix 自动发现及注册

1、依次选择 Configuratio、Discovery、Create discovery rule&#xff08;配置、自动发现、创建发现规则&#xff09; 创建客户端发现规则 2、zabbix客户端安装 agent zabbix客户端一键安装脚本 脚本参考链接 #!/bin/bash #Zabbix-Agent 5.0Zabbix_Service192.168.63.20#安…

2023牛客暑期多校训练营1(D/H/J/K/M)

目录 D.Chocolate H.Matches J.Roulette K.Subdivision M.Water D.Chocolate 思路&#xff1a;当n1且m1时候先手必输&#xff0c;然后1*k&#xff08;k>2&#xff09;的情况下后手必输&#xff0c;因为先手可以选到只剩下一个格子。而在其它情况里先手第一步可以先选(…

使用对象解构赋值,将对象的某些属性赋值给另一个对象

在处理接口返回的数据时&#xff0c;我需要将接口返回的数据&#xff08;对象&#xff09;的某些属性用另一个对象进行接收&#xff0c;学习对象解构赋值之前&#xff0c;我一直使用的都是最笨的方法&#xff1a; this.formData.projectId res.data.projectId this.formData.…

奖牌数领跑是为何?解码长沙华中医卫科技中等职业学校的国防教育成功之道

近些年&#xff0c;越来越多的学生、家长、企业开始重新审视职业教育的价值。在产教融合的大背景下&#xff0c;职业教育已经成为了高新产业发展的人才引擎&#xff0c;职业教育的教学模式、软硬件配置乃至未来毕业生的就业情况&#xff0c;已完全变了模样。 实际上&#xff0…

Linux环境下的开发工具(yum、vim、gdb、make/Makefile)

目录 yum vim GDB调试 Makefile yum 在Linux系统上安装软件的方式有 下载到程序的源代码&#xff0c;自行进行编译&#xff0c;得到可执行程序。 获取rpm安装包&#xff0c;通过rpm命令进行安装。&#xff08;未解决软件的依赖关系&#xff09; 通过yum进行安装软件。&…

Android APP性能及专项测试

Android篇 1. 性能测试 Android性能测试分为两类&#xff1a; 1、一类为rom版本&#xff08;系统&#xff09;的性能测试 2、一类为应用app的性能测试Android的app性能测试包括的测试项比如&#xff1a; 1、资源消耗 2、内存泄露 3、电量功耗 4、耗时 5、网络流量消耗 6、移动…