首页 车型大全 车型大全示例代码 根据ID获取车型详情[Python]

根据ID获取车型详情示例代码[Python]

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

根据ID获取车型详情

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

import urllib2, json, urllib


#  3、根据ID获取车型详情


data = {}
data["appkey"] = "your_appkey_here"
data["carid"] = 2571 #品牌ID

url_values = urllib.urlencode(data)
url = "https://api.jisuapi.com/car/detail" + "?" + url_values
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["id"],result["name"],result["initial"],result["parentid"],result["price"],result["yeartype"],result["productionstate"],result["salestate"],result["sizetype"],result["depth"]
if result.has_key("logo"):
    print result["logo"]
print "基本信息:"
basic = result["basic"]
print basic["price"],basic["saleprice"],basic["warrantypolicy"],basic["vechiletax"],basic["displacement"],basic["gearbox"],basic["comfuelconsumption"],basic["userfuelconsumption"],basic["officialaccelerationtime100"],basic["testaccelerationtime100"],basic["maxspeed"],basic["seatnum"]
print "车体:"
body = result["body"]
print body["color"],body["len"],body["width"],body["height"],body["wheelbase"],body["fronttrack"],body["reartrack"],body["weight"],body["fullweight"],body["mingroundclearance"],body["approachangle"],body["departureangle"],body["luggagevolume"],body["luggagemode"],body["luggageopenmode"],body["inductionluggage"],body["doornum"],body["tooftype"],body["hoodtype"],body["roofluggagerack"],body["sportpackage"]
print "发动机:"
engine = result["engine"]
print engine["position"],engine["model"],engine["displacement"],engine["displacementml"],engine["intakeform"],engine["cylinderarrangetype"],engine["cylindernum"],engine["valvetrain"],engine["valvestructure"],engine["compressionratio"],engine["bore"],engine["stroke"],engine["maxhorsepower"],engine["maxpower"],engine["maxpowerspeed"],engine["maxtorque"],engine["maxtorquespeed"],engine["fueltype"],engine["fuelgrade"],engine["fuelmethod"],engine["fueltankcapacity"],engine["cylinderheadmaterial"],engine["cylinderbodymaterial"],engine["environmentalstandards"],engine["startstopsystem"]

print "变速箱:"
gearbox = result["gearbox"]
print gearbox["gearbox"],gearbox["shiftpaddles"]
print "底盘制动:"
chassisbrake = result["chassisbrake"]
print chassisbrake["bodystructure"],chassisbrake["powersteering"],chassisbrake["frontbraketype"],chassisbrake["rearbraketype"],chassisbrake["parkingbraketype"],chassisbrake["drivemode"],chassisbrake["airsuspension"],chassisbrake["adjustablesuspension"],chassisbrake["frontsuspensiontype"],chassisbrake["rearsuspensiontype"],chassisbrake["centerdifferentiallock"]
print "安全配置:"
safe = result["safe"]
print safe["airbagdrivingposition"],safe["airbagfrontpassenger"],safe["airbagfrontside"],safe["airbagfronthead"],safe["airbagknee"],safe["airbagrearside"],safe["airbagrearhead"],safe["safetybeltprompt"],safe["safetybeltlimiting"],safe["safetybeltpretightening"],safe["frontsafetybeltadjustment"],safe["rearsafetybelt"],safe["tirepressuremonitoring"],safe["zeropressurecontinued"],safe["centrallocking"],safe["childlock"],safe["remotekey"],safe["keylessentry"],safe["keylessstart"],safe["engineantitheft"]
print "车轮:"
wheel = result["wheel"]
if wheel.has_key("wheel"):
    print wheel["wheel"]
print wheel["fronttiresize"],wheel["reartiresize"],wheel["sparetiretype"],wheel["hubmaterial"]
print "行车辅助:"
drivingauxiliary = result["drivingauxiliary"]
print drivingauxiliary["abs"],drivingauxiliary["ebd"],drivingauxiliary["brakeassist"],drivingauxiliary["tractioncontrol"],drivingauxiliary["esp"],drivingauxiliary["eps"],drivingauxiliary["automaticparking"],drivingauxiliary["hillstartassist"],drivingauxiliary["hilldescent"],drivingauxiliary["frontparkingradar"],drivingauxiliary["reversingradar"],drivingauxiliary["reverseimage"],drivingauxiliary["panoramiccamera"],drivingauxiliary["cruisecontrol"],drivingauxiliary["adaptivecruise"],drivingauxiliary["gps"],drivingauxiliary["automaticparkingintoplace"],drivingauxiliary["ldws"],drivingauxiliary["activebraking"],drivingauxiliary["integralactivesteering"],drivingauxiliary["nightvisionsystem"],drivingauxiliary["blindspotdetection"]
print "门窗后视镜:"
doormirror = result["doormirror"]
print doormirror["openstyle"],doormirror["electricwindow"],doormirror["uvinterceptingglass"],doormirror["privacyglass"],doormirror["antipinchwindow"],doormirror["skylightopeningmode"],doormirror["skylightstype"],doormirror["rearwindowsunshade"],doormirror["rearsidesunshade"],doormirror["rearwiper"],doormirror["sensingwiper"],doormirror["electricpulldoor"],doormirror["rearmirrorwithturnlamp"],doormirror["externalmirrormemory"],doormirror["externalmirrorheating"],doormirror["externalmirrorfolding"],doormirror["externalmirroradjustment"],doormirror["rearviewmirrorantiglare"],doormirror["sunvisormirror"]
print "灯光:"
light = result["light"]
if light.has_key("light"):
    print light["light"]
print light["headlighttype"],light["optionalheadlighttype"],light["headlightautomaticopen"],light["headlightautomaticclean"],light["headlightdelayoff"],light["headlightdynamicsteering"],light["headlightilluminationadjustment"],light["headlightdimming"],light["frontfoglight"],light["readinglight"],light["interiorairlight"],light["daytimerunninglight"],light["ledtaillight"],light["lightsteeringassist"]
print "内部配置:"
internalconfig = result["internalconfig"]
print internalconfig["steeringwheelbeforeadjustment"],internalconfig["steeringwheelupadjustment"],internalconfig["steeringwheeladjustmentmode"],internalconfig["steeringwheelmemory"],internalconfig["steeringwheelmaterial"],internalconfig["steeringwheelmultifunction"],internalconfig["steeringwheelheating"],internalconfig["computerscreen"],internalconfig["huddisplay"],internalconfig["interiorcolor"],internalconfig["rearcupholder"],internalconfig["supplyvoltage"]
print "座椅:"
seat = result["seat"]
print seat["sportseat"],seat["seatmaterial"],seat["seatheightadjustment"],seat["driverseatadjustmentmode"],seat["auxiliaryseatadjustmentmode"],seat["driverseatlumbarsupportadjustment"],seat["driverseatshouldersupportadjustment"],seat["frontseatheadrestadjustment"],seat["rearseatadjustmentmode"],seat["rearseatreclineproportion"],seat["rearseatangleadjustment"],seat["frontseatcenterarmrest"],seat["rearseatcenterarmrest"],seat["seatventilation"],seat["seatheating"],seat["seatmassage"],seat["electricseatmemory"],seat["childseatfixdevice"],seat["thirdrowseat"]
print "娱乐通讯:"
entcom = result["entcom"]
print entcom["locationservice"],entcom["bluetooth"],entcom["externalaudiointerface"],entcom["builtinharddisk"],entcom["cartv"],entcom["speakernum"],entcom["audiobrand"],entcom["dvd"],entcom["cd"],entcom["consolelcdscreen"],entcom["rearlcdscreen"]
print "空调冰箱:"
aircondrefrigerator = result["aircondrefrigerator"]
print aircondrefrigerator["airconditioningcontrolmode"],aircondrefrigerator["tempzonecontrol"],aircondrefrigerator["rearairconditioning"],aircondrefrigerator["reardischargeoutlet"],aircondrefrigerator["airconditioning"],aircondrefrigerator["airpurifyingdevice"],aircondrefrigerator["carrefrigerator"]
print "实际测试:"
actualtest = result["actualtest"]
print actualtest["accelerationtime100"],actualtest["brakingdistance"]