我们都知道淘宝平台推出了拍立淘功能,如果大家遇到了自己喜欢的商品,就可以拍一张照片,在淘宝用拍立淘搜索就能够出现相似的同款,这样就不用再去找别人要链接了。淘宝拍立淘主要是通过图片识别来找相似主图的宝贝,那么第三方软件如何实现批量按图片搜索淘宝商品,批量获取商品详情数据呢?
前段时间我试着利用网络爬虫技术,将拍立淘功能封装成一个API接口,调用此接口,即可轻松实现图片搜索商品功能。该API请求参数为图片地址(支持淘宝或天猫图片地址,外部地址先调用上传图片(upload_img)接口,返回图片地址)。
接口名称:item_search_img 图片搜索商品(拍立淘)
upload_img-上传图片到淘宝
-- 请求示例 url 默认请求参数已经URL编码处理 curl -i "https://api-服务器.cn/taobao/item_search_img/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&imgid=http://g-search3.alicdn.com/img/bao/uploaded/i4/O1CN01IDpcD81zHbpHs1YgT_!!2200811456689.jpg&cat="
响应示例(部分返回数据)
"items": {
"pagecount": 1,
"total_results": 31,
"real_total_results": 31,
"item": [
{
"title": "运动袜子男士中筒夏季防臭棉袜加厚毛巾底专业跑步马拉松实战篮球",
"pic_url": "https://img.alicdn.com/img/bao/uploaded/i4//i3/32587954/O1CN01vcp9tY28cz7FFb1sW_!!0-saturn_solar.jpg",
"promotion_price": "59",
"price": "59",
"sales": 23,
"num_iid": "695040717762",
"post_fee": null,
"sample_id": "",
"seller_nick": null,
"is_tmall": "false",
"area": "绍兴",
"detail_url": "//item.taobao.com/item.htm?id=695040717762",
"cid": null
},
{
"title": "准者篮球袜子中长筒美式运动跑步球员实战毛巾底加厚精英袜男夏季",
"pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN018xCrFz1uhC6pepgk7_!!2452776068.jpg",
"promotion_price": "10.9",
"price": "10.9",
"sales": 5,
"num_iid": "678783946589",
"post_fee": null,
"sample_id": "",
"seller_nick": null,
"is_tmall": "false",
"area": "泉州",
"detail_url": "//item.taobao.com/item.htm?id=678783946589",
"cid": "50017261"
},
{
"title": "JumpStart 拼色篮球精英袜 虎扑jrs推荐潮流拼多色缓压减震运动袜",
"pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01RT9Z4l2NMhEHYicuA_!!2201506239949.jpg",
"promotion_price": "29",
"price": "29",
"sales": 1,
"num_iid": "679924181447",
"post_fee": null,
"sample_id": "",
"seller_nick": null,
"is_tmall": "false",
"area": "上海",
"detail_url": "//item.taobao.com/item.htm?id=679924181447",
"cid": "50015374"
},
{
"title": "斗牛专业实战球员版精英篮球袜子男中高筒加厚毛巾底高帮运动袜子",
"pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01noBgTm21LqsICG2Os_!!1983416969.jpg",
"promotion_price": "12.8",
"price": "12.8",
"sales": 49,
"num_iid": "647075735380",
"post_fee": null,
"sample_id": "",
"seller_nick": null,
"is_tmall": "false",
"area": "广州",
"detail_url": "//item.taobao.com/item.htm?id=647075735380",
"cid": "50017261"
},
{
"title": "likeid篮球袜美式中长筒袜男夏季专业实战精英袜训练防滑运动袜子",
"pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01vuh3G31RMTNN47D8h_!!623082097.jpg",
"promotion_price": "11.9",
"price": "11.9",
"sales": 174,
"num_iid": "706255675043",
"post_fee": null,
"sample_id": "",
"seller_nick": null,
"is_tmall": "false",
"area": "佛山",
"detail_url": "//item.taobao.com/item.htm?id=706255675043",
"cid": "50017261"
},
{
"title": "篮球袜子中长筒短筒高帮跑步袜男士户外专业运动加厚毛巾底精英袜",
"pic_url": "https://img.alicdn.com/img/bao/uploaded/i4/O1CN01tiizk31ph7k5Vutd4_!!271045391.jpg",
"promotion_price": "6.8",
"price": "6.8",
"sales": 2,
"num_iid": "600321872541",
"post_fee": null,
"sample_id": "",
"seller_nick": null,
"is_tmall": "false",
"area": "杭州",
"detail_url": "//item.taobao.com/item.htm?id=600321872541",
"cid": "50017261"
},
公共参数
名称 | 类型 | 必须 | 描述 |
---|---|---|---|
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版本 |
upload_img请求参数说明
upload_img响应参数说明