首页 商品条码查询 商品条码查询示例代码 条码查询requests版[Python]

条码查询requests版示例代码Python

作者:liuxiaojie 阅读数:2713 上传时间:2016-03-10

条码查询requests版

#!/usr/bin/python
# encoding:utf-8

import requests

#  1、条码查询

data = {}
data["appkey"] = "your_appkey_here"
data["barcode"] = "06917878036526"
url = "https://api.jisuapi.com/barcode2/query"
print(url)
response = requests.get(url,params=data)
jsonarr = response.json()
if jsonarr["status"] != 0:
    print(jsonarr["msg"])
    exit()
result = jsonarr["result"]
print(result["barcode"],result["name"],result["ename"],result["unspsc"])
print(result["brand"],result["width"],result["height"])
print(result["depth"],result["origincountry"],result["originplace"],result["assemblycountry"])
print(result["barcodetype"],result["catena"],result["isbasicunit"],result["packagetype"])
print(result["grossweight"],result["netcontent"],result["netweight"],result["description"])
print(result["keyword"],result["pic"],result["price"],result["licensenum"],result["healthpermitnum"])