首页 条码查询 条码查询示例代码 条码查询[Python]

条码查询示例代码[Python]

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

条码查询

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

import urllib2, json, urllib



#  1、条码查询


data = {}
data["appkey"] = "your_appkey_here"
data["barcode"] = "06917878036526"

url_values = urllib.urlencode(data)
url = "https://api.jisuapi.com/barcode2/query" + "?" + url_values
print url

request = urllib2.Request(url)
result = urllib2.urlopen(request)
jsonarr = json.loads(result.read())

if jsonarr["status"] != u"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"]