Chinaunix首页 | 论坛 | 博客
  • 博客访问: 721
  • 博文数量: 6
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 70
  • 用 户 组: 普通用户
  • 注册时间: 2024-10-10 10:46
文章分类
文章存档

2024年(6)

我的朋友
最近访客

分类: Python/Ruby

2024-10-10 10:55:22

要在Python前端通过API接口调用与后端进行数据交互并获取商品详情信息数据,可以通过封装好的api接口通过链接直接请求获取商品数据,以下是接入api的请求示例:

		
  1. # coding:utf-8
  2. """
  3. Compatible for python2.x and python3.x
  4. requirement: pip install requests
  5. """
  6. from __future__ import print_function
  7. import requests
  8. # 请求示例 url 默认请求参数已经做URL编码
  9. url = "https://taobao/item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=652874751412&is_promotion=1"
  10. headers = {
  11. "Accept-Encoding": "gzip",
  12. "Connection": "close"
  13. }
  14. if __name__ == "__main__":
  15. r = requests.get(url, headers=headers)
  16. json_obj = r.json()
  17. print(json_obj)

item_get-获得商品详情(注册获取接入key和secret

公共参数

名称 类型 必须 描述
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版本


请求参数

请求参数:num_iid=652874751412&is_promotion=1

参数说明:num_iid:商品ID
is_promotion:是否获取取促销价

响应示例

		
  1. "item": {
  2. "num_iid": "652874751412",
  3. "title": "奶油风布艺沙发现代简约轻奢小户型客厅直排可拆洗沙发原木可定制",
  4. "desc_short": "",
  5. "price": 480,
  6. "total_price": "",
  7. "suggestive_price": "",
  8. "orginal_price": 480,
  9. "nick": "惜情yqq1127",
  10. "num": 200,
  11. "detail_url": "https://item.taobao.com/item.htm?id=652874751412",
  12. "pic_url": "//img.alicdn.com/imgextra/i4/2568161054/O1CN01aYBriY1Jem9UDtt9e_!!2568161054.jpg",
  13. "brand": "#0 工厂",
  14. "brandId": "",
  15. "rootCatId": "",
  16. "cid": 50020632,
  17. "desc": "
    \n
    \n http://img.alicdn.com/imgextra/i3/2568161054/O1CN01LFmSOU1Jem9QOjMPb_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i3/2568161054/O1CN014vyOOT1Jem9DpHz3Y_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i1/2568161054/O1CN01B3PpsA1Jem9N8V7uf_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i2/2568161054/O1CN015JbyeY1Jem9MZshUt_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i1/2568161054/O1CN01HXSoxx1Jem9RvgzHN_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i3/2568161054/O1CN01IEultA1Jem9MdEx8R_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i3/2568161054/O1CN0176K98O1Jem9QOjE69_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i4/2568161054/O1CN013Pxp1O1Jem9RvgeTv_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i1/2568161054/O1CN01SfyZ8M1Jem9QOi1Gx_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i4/2568161054/O1CN01bb1POa1Jem9Sdgve2_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i3/2568161054/O1CN018Eo9dV1Jem9KV0y79_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i1/2568161054/O1CN01vuEofr1Jem9Nzy9xY_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i4/2568161054/O1CN01qw9sAi1Jem8wkNKpy_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i1/2568161054/O1CN01HeFhFw1Jem8rLnjBY_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i2/2568161054/O1CN01SNgjoi1Jem9QOil15_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i2/2568161054/O1CN01RXf3RA1Jem9DpHVwj_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i4/2568161054/O1CN01gZmZjt1Jem9ISThgm_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i2/2568161054/O1CN01YL0FHM1Jem9PQTjX9_!!2568161054.jpg\" />\n http://img.alicdn.com/imgextra/i4/2568161054/O1CN01UhsEhZ1Jem8yvJIhZ_!!2568161054.jpg\" />\n
    \n
    https://www.o0b.cn/i.php?t.png&rid=gw-1.664db3ffb71e1&p=1778845177&k=i_key&t=1716368389\" style=\"display:none\" />",
  18. "item_imgs": [
  19. {
  20. "url": "//img.alicdn.com/imgextra/i4/2568161054/O1CN01aYBriY1Jem9UDtt9e_!!2568161054.jpg"
  21. },
  22. {
  23. "url": "//img.alicdn.com/imgextra/i3/2568161054/O1CN01kjOfNb1Jem9DmWn8Y_!!2568161054.jpg"
  24. },
  25. {
  26. "url": "//img.alicdn.com/imgextra/i1/2568161054/O1CN01HoB9ha1Jem9DmWn8r_!!2568161054.jpg"
  27. },
  28. {
  29. "url": "//img.alicdn.com/imgextra/i4/2568161054/O1CN011PjP2P1Jem9MXEUFT_!!2568161054.jpg"
  30. },
  31. {
  32. "url": "//img.alicdn.com/imgextra/i3/2568161054/O1CN01KUfBFL1Jem9KTTMn1_!!2568161054.jpg"
  33. }
  34. ],
  35. "item_weight": "",
  36. "post_fee": 0,
  37. "freight": "",
  38. "express_fee": "",
  39. "ems_fee": "",
  40. "shipping_to": "",
  41. "video": {
  42. "url": "https://cloud.video.taobao.com/play/u/2568161054/p/2/e/6/t/1/428224913062.mp4?appKey=38829"
  43. },
  44. "sample_id": "",
  45. "props_name": "31480:14306495906:几人坐:脚踏90*60*48cm;31480:14306495907:几人坐:双人165*95*67cm;31480:14306495908:几人坐:三人210*95*67cm;31480:14306495909:几人坐:单人100*95*67cm;31480:21480914361:几人坐:四人位240*95*67cm;31480:21480914362:几人坐:大四人320*95*76cm;31480:1387571900:几人坐:3米贵妃沙发;31480:32527954:几人坐:定制尺寸;1627207:28321:颜色分类:乳白色 尺寸颜色可定制;1627207:28321:颜色分类:乳白色 尺寸颜色可定制;1627207:28321:颜色分类:乳白色 尺寸颜色可定制;1627207:28321:颜色分类:乳白色 尺寸颜色可定制;1627207:28321:颜色分类:乳白色 尺寸颜色可定制;1627207:28321:颜色分类:乳白色 尺寸颜色可定制;1627207:28321:颜色分类:乳白色 尺寸颜色可定制;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
  46. "prop_imgs": {
  47. "prop_img": [
  48. {
  49. "properties": "1627207:28321",
  50. "url": "//img.alicdn.com/imgextra/i1/2568161054/O1CN017GTZ4h1Jem9Qra1ap_!!2568161054.jpg"
  51. }
  52. ]
  53. },
  54. "props_imgs": {
  55. "prop_img": [
  56. {
  57. "properties": "1627207:28321",
  58. "url": "//img.alicdn.com/imgextra/i1/2568161054/O1CN017GTZ4h1Jem9Qra1ap_!!2568161054.jpg"
  59. }
  60. ]
  61. },
  62. "property_alias": "",
  63. "props": [
  64. {
  65. "name": "品牌",
  66. "value": "#0 工厂"
  67. },
  68. {
  69. "name": "型号",
  70. "value": "520"
  71. },
  72. {
  73. "name": "材质",
  74. "value": "木"
  75. },
  76. {
  77. "name": "木质材质",
  78. "value": "松木"
  79. },
  80. {
  81. "name": "面料",
  82. "value": "绒布"
  83. },
  84. {
  85. "name": "风格",
  86. "value": "北欧"
  87. },
  88. {
  89. "name": "几人坐",
  90. "value": "脚踏90*60*48cm,双人165*95*67cm,三人210*95*67cm,单人100*95*67cm,四人位240*95*67cm,大四人320*95*76cm,3米贵妃沙发,定制尺寸"
  91. },
  92. {
  93. "name": "颜色分类",
  94. "value": "乳白色"
  95. },
  96. {
  97. "name": "填充物",
  98. "value": "海绵"
  99. },
  100. {
  101. "name": "结构工艺",
  102. "value": "木质工艺"
  103. },
  104. {
  105. "name": "是否可定制",
  106. "value": "是"
  107. },
  108. {
  109. "name": "沙发组合形式",
  110. "value": "U形"
  111. },
  112. {
  113. "name": "是否可拆洗",
  114. "value": "是"
  115. },
  116. {
  117. "name": "适用对象",
  118. "value": "成年人"
  119. },
  120. {
  121. "name": "是否带储物空间",
  122. "value": "否"
  123. },
  124. {
  125. "name": "产地",
  126. "value": "上海"
  127. },
  128. {
  129. "name": "地市",
  130. "value": "上海市"
  131. },
  132. {
  133. "name": "区县",
  134. "value": "奉贤区"
  135. },
  136. {
  137. "name": "是否组装",
  138. "value": "否"
  139. },
  140. {
  141. "name": "出租车是否可运输",
  142. "value": "否"
  143. },
  144. {
  145. "name": "填充物硬度",
  146. "value": "软"
  147. },
  148. {
  149. "name": "款式定位",
  150. "value": "经济型"
  151. }
  152. ],
  153. "total_sold": "-1",
  154. "skus": {
  155. "sku": [
  156. {
  157. "price": 480,
  158. "total_price": 0,
  159. "orginal_price": 480,
  160. "properties": "31480:14306495906;1627207:28321",
  161. "properties_name": "31480:14306495906:几人坐:脚踏90*60*48cm;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
  162. "quantity": 200,
  163. "sku_id": "4881047531343"
  164. },
  165. {
  166. "price": 1688,
  167. "total_price": 0,
  168. "orginal_price": 1688,
  169. "properties": "31480:14306495907;1627207:28321",
  170. "properties_name": "31480:14306495907:几人坐:双人165*95*67cm;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
  171. "quantity": 129,
  172. "sku_id": "4881047531344"
  173. },
  174. {
  175. "price": 2088,
  176. "total_price": 0,
  177. "orginal_price": 2088,
  178. "properties": "31480:14306495908;1627207:28321",
  179. "properties_name": "31480:14306495908:几人坐:三人210*95*67cm;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
  180. "quantity": 186,
  181. "sku_id": "4881047531345"
  182. },
  183. {
  184. "price": 968,
  185. "total_price": 0,
  186. "orginal_price": 968,
  187. "properties": "31480:14306495909;1627207:28321",
  188. "properties_name": "31480:14306495909:几人坐:单人100*95*67cm;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
  189. "quantity": 200,
  190. "sku_id": "4881047531346"
  191. },
  192. {
  193. "price": 2388,
  194. "total_price": 0,
  195. "orginal_price": 2388,
  196. "properties": "31480:21480914361;1627207:28321",
  197. "properties_name": "31480:21480914361:几人坐:四人位240*95*67cm;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
  198. "quantity": 200,
  199. "sku_id": "5039985183001"
  200. },
  201. {
  202. "price": 3188,
  203. "total_price": 0,
  204. "orginal_price": 3188,
  205. "properties": "31480:21480914362;1627207:28321",
  206. "properties_name": "31480:21480914362:几人坐:大四人320*95*76cm;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
  207. "quantity": 200,
  208. "sku_id": "5039985183002"
  209. },
  210. {
  211. "price": 3400,
  212. "total_price": 0,
  213. "orginal_price": 3400,
  214. "properties": "31480:1387571900;1627207:28321",
  215. "properties_name": "31480:1387571900:几人坐:3米贵妃沙发;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
  216. "quantity": 200,
  217. "sku_id": "5039984824000"
  218. },
  219. {
  220. "price": 3000,
  221. "total_price": 0,
  222. "orginal_price": 3000,
  223. "properties": "31480:32527954;1627207:28321",
  224. "properties_name": "31480:32527954:几人坐:定制尺寸;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
  225. "quantity": 200,
  226. "sku_id": "5039985183003"
  227. }
  228. ]
  229. },
  230. "seller_id": "2568161054",
  231. "sales": 0,
  232. "shop_id": "567158267",
  233. "props_list": {
  234. "31480:14306495906": "几人坐:脚踏90*60*48cm",
  235. "31480:14306495907": "几人坐:双人165*95*67cm",
  236. "31480:14306495908": "几人坐:三人210*95*67cm",
  237. "31480:14306495909": "几人坐:单人100*95*67cm",
  238. "31480:21480914361": "几人坐:四人位240*95*67cm",
  239. "31480:21480914362": "几人坐:大四人320*95*76cm",
  240. "31480:1387571900": "几人坐:3米贵妃沙发",
  241. "31480:32527954": "几人坐:定制尺寸",
  242. "1627207:28321": "颜色分类:乳白色 尺寸颜色可定制"
  243. },
  244. "seller_info": {
  245. "nick": "惜情yqq1127",
  246. "item_score": 5,
  247. "score_p": 5,
  248. "delivery_score": 5,
  249. "shop_type": "",
  250. "user_num_id": "2568161054",
  251. "sid": null,
  252. "title": "",
  253. "zhuy": "https://shop567158267/.taobao.com",
  254. "cert": null,
  255. "open_time": "",
  256. "credit_score": "tb-rank-blue:4",
  257. "shop_name": "佑安居"
  258. },
  259. "tmall": false,
  260. "error": "",
  261. "location": "江苏南通",
  262. "data_from": "ha",
  263. "has_discount": "false",
  264. "is_promotion": "false",
  265. "promo_type": null,
  266. "props_img": {
  267. "1627207:28321": "//img.alicdn.com/imgextra/i1/2568161054/O1CN017GTZ4h1Jem9Qra1ap_!!2568161054.jpg"
  268. },
  269. "format_check": "ok",
  270. "desc_img": [
  271. "http://img.alicdn.com/imgextra/i3/2568161054/O1CN01LFmSOU1Jem9QOjMPb_!!2568161054.jpg",
  272. "http://img.alicdn.com/imgextra/i3/2568161054/O1CN014vyOOT1Jem9DpHz3Y_!!2568161054.jpg",
  273. "http://img.alicdn.com/imgextra/i1/2568161054/O1CN01B3PpsA1Jem9N8V7uf_!!2568161054.jpg",
  274. "http://img.alicdn.com/imgextra/i2/2568161054/O1CN015JbyeY1Jem9MZshUt_!!2568161054.jpg",
  275. "http://img.alicdn.com/imgextra/i1/2568161054/O1CN01HXSoxx1Jem9RvgzHN_!!2568161054.jpg",
  276. "http://img.alicdn.com/imgextra/i3/2568161054/O1CN01IEultA1Jem9MdEx8R_!!2568161054.jpg",
  277. "http://img.alicdn.com/imgextra/i3/2568161054/O1CN0176K98O1Jem9QOjE69_!!2568161054.jpg",
  278. "http://img.alicdn.com/imgextra/i4/2568161054/O1CN013Pxp1O1Jem9RvgeTv_!!2568161054.jpg",
  279. "http://img.alicdn.com/imgextra/i1/2568161054/O1CN01SfyZ8M1Jem9QOi1Gx_!!2568161054.jpg",
  280. "http://img.alicdn.com/imgextra/i4/2568161054/O1CN01bb1POa1Jem9Sdgve2_!!2568161054.jpg",
  281. "http://img.alicdn.com/imgextra/i3/2568161054/O1CN018Eo9dV1Jem9KV0y79_!!2568161054.jpg",
  282. "http://img.alicdn.com/imgextra/i1/2568161054/O1CN01vuEofr1Jem9Nzy9xY_!!2568161054.jpg",
  283. "http://img.alicdn.com/imgextra/i4/2568161054/O1CN01qw9sAi1Jem8wkNKpy_!!2568161054.jpg",
  284. "http://img.alicdn.com/imgextra/i1/2568161054/O1CN01HeFhFw1Jem8rLnjBY_!!2568161054.jpg",
  285. "http://img.alicdn.com/imgextra/i2/2568161054/O1CN01SNgjoi1Jem9QOil15_!!2568161054.jpg",
  286. "http://img.alicdn.com/imgextra/i2/2568161054/O1CN01RXf3RA1Jem9DpHVwj_!!2568161054.jpg",
  287. "http://img.alicdn.com/imgextra/i4/2568161054/O1CN01gZmZjt1Jem9ISThgm_!!2568161054.jpg",
  288. "http://img.alicdn.com/imgextra/i2/2568161054/O1CN01YL0FHM1Jem9PQTjX9_!!2568161054.jpg",
  289. "http://img.alicdn.com/imgextra/i4/2568161054/O1CN01UhsEhZ1Jem8yvJIhZ_!!2568161054.jpg"
  290. ],
  291. "shop_item": [],
  292. "relate_items": []
  293. },
  294. "error": "",
  295. "secache": "4ad7ad2480af253fec9c2fd4daa266bb",
  296. "secache_time": 1716368389,
  297. "secache_date": "2024-05-22 16:59:49",
  298. "translate_status": "",
  299. "translate_time": 0,
  300. "language": {
  301. "default_lang": "cn",
  302. "current_lang": "cn"
  303. },
  304. "reason": "",
  305. "error_code": "0000"
阅读(65) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:如何利用Python接入淘宝API获取商品信息

给主人留下些什么吧!~~