按关键字搜索商品API接口通常用于根据关键字搜索商品,并返回商品的相关信息。以下是一个示例,说明如何使用Python调用按关键字搜索商品API接口。
item_search-按关键字搜索淘宝商品
公共参数
API接口请求地址:调用key
名称 | 类型 | 必须 | 描述 |
---|---|---|---|
key | String | 是 | 调用key(必须以GET方式拼接在URL中) |
secret | String | 是 | 调用密钥 |
api_name | String | 是 | API接口名称(包括在请求地址中)[item_search,item_get,item_search_shop等] |
cache | String | 否 | [yes,no]默认yes,将调用缓存的数据,速度比较快 |
result_type | String | 否 | [json,jsonu,xml,serialize,var_export]返回数据格式,默认为json,jsonu输出的内容中文可以直接阅读 |
lang | String | 否 | [cn,en,ru]翻译语言,默认cn简体中文 |
version | String | 否 | API版本 |
请求参数
请求参数:q=女装&start_price=0&end_price=0&page=1&cat=0&discount_only=&sort=&page_size=&seller_info=&nick=&ppath=&imgid=&filter=
参数说明:q:搜索关键字
sort:排序[bid,_bid,bid2,_bid2,_sale,_credit]
(bid:总价,bid2:商品价格,sale:销量,credit信用,加_前缀为从大到小排序)
page:页数
我们可以编写以下Python代码来调用商品详情API接口:
# coding:utf-8
"""
Compatible for python2.x and python3.x
requirement: pip install requests
"""
from __future__ import print_function
import requests
# 请求示例 url 默认请求参数已经做URL编码
url = "https://item_search/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&q=女装&start_price=0&end_price=0&page=1&cat=0&discount_only=&sort=&page_size=&seller_info=&nick=&ppath=&imgid=&filter="
headers = {"Accept-Encoding": "gzip","Connection": "close"
}
if __name__ == "__main__":r = requests.get(url, headers=headers)json_obj = r.json()print(json_obj)
请注意,您需要将num_iid
和api_key
替换为实际的id和apisecret。此外,您可能需要根据实际的API响应格式调整代码中的键名。
API接口响应示例
{"items": {"page": "1","real_total_results": 2000,"total_results": 2000,"page_size": 30,"pagecount": 30,"_ddf": "ti","item": [{"title": "11年老店 超20种颜色女装中长款宽松无袖t恤女圆领纯棉打底夏季体恤","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01L9PVRW2HEYY6bc4qQ_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 89,"promotion_price": 89,"price": 89,"sales": 400,"num_iid": "528015401437","seller_nick": "独白睫 香港高端T恤品牌","detail_url": "https://item.taobao.com/item.htm?id=528015401437"},{"title": "大码裤子女2024新款爆款九分裤胖mm高腰休闲西装裤小个子哈伦裤夏","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01xYzoK11DKGy6dLCNL_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 129,"promotion_price": "79.00","price": "79.00","sales": 0,"num_iid": "780488377278","seller_nick": "颜筱旗舰店","detail_url": "https://item.taobao.com/item.htm?id=780488377278"},{"title": "2024西装裤子女春夏职业九分薄款烟管裤高腰八分黑色小脚西裤女","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN016lWQoc2FEtWUcsGoj_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 278,"promotion_price": "139.00","price": "139.00","sales": 900,"num_iid": "650313101003","seller_nick": "忆芳园工厂店","detail_url": "https://item.taobao.com/item.htm?id=650313101003"},{"title": "贝茜妮法式天丝气质收腰连衣裙女2024夏季新款宽松v领显瘦短袖裙","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01JVQN741D3KJIQ1KtC_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 658,"promotion_price": "559.00","price": "559.00","sales": 81,"num_iid": "775408938870","seller_nick": "贝茜妮服饰旗舰店","detail_url": "https://item.taobao.com/item.htm?id=775408938870"},{"title": "betu百图女装2024夏季新款新中式盘扣国风绣花短袖衬衫衬衣上衣","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01kP0oh01OBzaCF3OPX_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 329,"promotion_price": "299.00","price": "299.00","sales": 1000,"num_iid": "768907527539","seller_nick": "betu旗舰店","detail_url": "https://item.taobao.com/item.htm?id=768907527539"},{"title": "贝茜妮法式学院风撞色条纹衬衫女2024春季新款设计感长袖衬衣上衣","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN0117yuOw1D3KI4zzduj_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 448,"promotion_price": "379.00","price": "379.00","sales": 300,"num_iid": "763864215578","seller_nick": "贝茜妮服饰旗舰店","detail_url": "https://item.taobao.com/item.htm?id=763864215578"},{"title": "2024夏装新款ins网红西装裤高级垂感小众宽松拖地阔腿裤女潮","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN011ViObr1D8MfkNT3pk_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 354,"promotion_price": 354,"price": 354,"sales": 0,"num_iid": "780641373535","seller_nick": "FOR OU","detail_url": "https://item.taobao.com/item.htm?id=780641373535"},{"title": "11年老店 超20种颜色女装jk制服套装女童上衣衬衫短袖夏季裙子全套小学生jk格裙儿童百褶裙","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01ipEkI422MbCdXkQph_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 150,"promotion_price": "150.00","price": "150.00","sales": 2,"num_iid": "674882807587","seller_nick": "小野琳JK制服套装女童","detail_url": "https://item.taobao.com/item.htm?id=674882807587"},{"title": "正品保证 职业装女装套裙夏季时尚气质空姐制服短袖西装正装酒店美容院工装","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01u4mWVx1bKlk7TmC7i_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 336,"promotion_price": "228.00","price": "228.00","sales": 0,"num_iid": "566780248499","seller_nick": "弦念旗舰店","detail_url": "https://item.taobao.com/item.htm?id=566780248499"},{"title": "2024春夏秋款西装裤女九分高腰休闲烟管裤OL职业加绒黑色小脚裤女","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01VsxUvG2FEtZOP3767_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 278,"promotion_price": "139.00","price": "139.00","sales": 200,"num_iid": "684276200975","seller_nick": "忆芳园工厂店","detail_url": "https://item.taobao.com/item.htm?id=684276200975"},{"title": "九年老店 女装播音艺考主持正装连衣裙2022年春秋新款","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01xQxdDe1yg3XnoFRkp_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 312,"promotion_price": "218.00","price": "218.00","sales": 0,"num_iid": "665394108962","seller_nick": "逸美人女装","detail_url": "https://item.taobao.com/item.htm?id=665394108962"},{"title": "收腹神器配大码女装2022新款冬装胖mm高端减龄年轻巨显瘦穿搭遮肉","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01RATSKt1CPTiKiBZJw_!!2-saturn_solar.png_sum.jpg","orginal_price": 228,"promotion_price": "228.00","price": "228.00","sales": 6,"num_iid": "693520763770","seller_nick": "蓝胖子专官店","detail_url": "https://item.taobao.com/item.htm?id=693520763770"},{"title": "艾尚臣女装 12年老店 十种颜色艾尚臣女装春秋西装外套女职业装英伦风高级感休闲西服套装韩版正装ol工作服","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01Q58BIa1KIAGBg8DtU_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 830,"promotion_price": "830.00","price": "830.00","sales": 100,"num_iid": "655225159038","seller_nick": "艾尚臣旗舰店","detail_url": "https://item.taobao.com/item.htm?id=655225159038"},{"title": "五年老店 民国风古装太太贵妇人装酒会礼服舞台表演服","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN019Va7WD1C4rjEtThSL_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 128,"promotion_price": "105.00","price": "105.00","sales": 67,"num_iid": "614077706672","seller_nick": "春风十里古装工厂店","detail_url": "https://item.taobao.com/item.htm?id=614077706672"},{"title": "YUZI上衣衬衫基础百搭鱼子大码女装微胖mm显瘦遮肉200斤宽松减龄","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01OcDhXm1C9RwyKcV4z_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 139,"promotion_price": "99.00","price": "99.00","sales": 91,"num_iid": "732219659957","seller_nick": "YUZI鱼子 大码风潮工作室","detail_url": "https://item.taobao.com/item.htm?id=732219659957"},{"title": "重磅真丝衬衫女长袖2024年新款贵夫人气质衬衣高端大牌桑蚕丝上衣","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN012TwTT91Bx5IUov5nJ_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 1580,"promotion_price": "158.00","price": "158.00","sales": 8,"num_iid": "665717509952","seller_nick": "杭州真丝衬衫工厂店","detail_url": "https://item.taobao.com/item.htm?id=665717509952"},{"title": "2023新店 夜总会显瘦蹦迪新款夜店女装气质裙子短裙性","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01yqZBYq22jV43m4dIu_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 168,"promotion_price": "88.00","price": "88.00","sales": 1,"num_iid": "706428699461","seller_nick": "季卡娜旗舰店","detail_url": "https://item.taobao.com/item.htm?id=706428699461"},{"title": "恒源祥中老年夏装真丝衬衫女宽松妈妈夏季薄款香云纱桑蚕丝上衣女","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01JN9Zwa1a7Ci5GF0cm_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 960,"promotion_price": "168.00","price": "168.00","sales": 0,"num_iid": "707632790705","seller_nick": "缘来依佳","detail_url": "https://item.taobao.com/item.htm?id=707632790705"},{"title": "恒源祥2023新款妈妈夏装真丝衬衫女中老年宽松印花衬衣桑蚕丝上衣","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01COZQ9N1a7Ci8HRPrr_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 960,"promotion_price": "168.00","price": "168.00","sales": 0,"num_iid": "707560480100","seller_nick": "缘来依佳","detail_url": "https://item.taobao.com/item.htm?id=707560480100"},{"title": "高腰阔腿牛仔裤女春夏爆款2024年新款显瘦百搭垂感直筒拖地裤子","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01a2Gg5S1CE1itf2WpJ_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 99,"promotion_price": "69.00","price": "69.00","sales": 20000,"num_iid": "657506966055","seller_nick": "caiwinking旗舰店","detail_url": "https://item.taobao.com/item.htm?id=657506966055"},{"title": "播阔腿西装裤女2024春夏新款通勤时尚高级感直筒裤子DDR2KD5770","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01c1iXx61nE9qih9uuM_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 798,"promotion_price": "464.00","price": "464.00","sales": 8,"num_iid": "778445449846","seller_nick": "播官方旗舰店","detail_url": "https://item.taobao.com/item.htm?id=778445449846"},{"title": "咖色窄版阔腿裤女夏季薄款高级感冰丝裤子小个子直筒裤垂感西装裤","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01kv9quc2E6MjTk9K6U_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 199,"promotion_price": "178.00","price": "178.00","sales": 4,"num_iid": "712329548965","seller_nick": "锐帛旗舰店","detail_url": "https://item.taobao.com/item.htm?id=712329548965"},{"title": "九年老店 超20种颜色女装高级感竹纤维男女同款职业装衬衫OL短袖套装夏季美容师工作服女裙","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01TENSta1bKlzLJd3zF_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 316,"promotion_price": "158.00","price": "158.00","sales": 58,"num_iid": "669727833219","seller_nick": "弦念旗舰店","detail_url": "https://item.taobao.com/item.htm?id=669727833219"},{"title": "年轻妈妈夏装洋气雪纺连衣裙40岁50中年女装酒红色气质中长款裙子","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01Cb8Qut2KXk5tyPP0m_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 268,"promotion_price": "178.00","price": "178.00","sales": 69,"num_iid": "676976532147","seller_nick": "羽佩旗舰店","detail_url": "https://item.taobao.com/item.htm?id=676976532147"},{"title": "杭州重磅真丝衬衫女士2024年新款贵夫人印花衬衣大牌桑蚕丝上衣","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01RzS7RG1Bx5ALigvL5_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 1580,"promotion_price": "158.00","price": "158.00","sales": 22,"num_iid": "701313466940","seller_nick": "杭州真丝衬衫工厂店","detail_url": "https://item.taobao.com/item.htm?id=701313466940"},{"title": "高级感黑色西装外套女早春秋装新款韩版休闲西服","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01iriAQu1C0Hu6o2cuf_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 588,"promotion_price": "168.00","price": "168.00","sales": 1000,"num_iid": "681219742538","seller_nick": "芷澈服饰 高端定制","detail_url": "https://item.taobao.com/item.htm?id=681219742538"},{"title": "白色阔腿裤女2024新款春秋高腰垂感窄版西装直筒裤加长高个子裤子","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01TRKSQ51CdDipKIhiK_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 258,"promotion_price": "258.00","price": "258.00","sales": 3,"num_iid": "768568100023","seller_nick": "苡苜旗舰店","detail_url": "https://item.taobao.com/item.htm?id=768568100023"},{"title": "九年老店 超20种颜色女装职业通勤黑色小直筒休闲百搭工装长裤女九分","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01hlA7km1OUJ4NNk6qV_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 155.9,"promotion_price": "79.00","price": "79.00","sales": 900,"num_iid": "43920761180","seller_nick": "miss丹家 絮迹","detail_url": "https://item.taobao.com/item.htm?id=43920761180"},{"title": "真丝裤子女2021夏新款宽松桑蚕丝九分哈伦裤","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01SQLgqT2MHMuYN9Tsg_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 530,"promotion_price": "338.00","price": "338.00","sales": 2,"num_iid": "638705516027","seller_nick": "恋那丝旗舰店","detail_url": "https://item.taobao.com/item.htm?id=638705516027"},{"title": "日本2023年夏季新款醋酸冰丝直筒高腰阔腿裤女纯色薄款垂感休闲裤","pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01GEwvyx1fLvcs5T3Op_!!0-saturn_solar.jpg_sum.jpg","orginal_price": 920,"promotion_price": "328.00","price": "328.00","sales": 0,"num_iid": "711340193585","seller_nick": "日系 SDY SHOP","detail_url": "https://item.taobao.com/item.htm?id=711340193585"}],"item_weight_update": 0},"error_code": "0000"