基于Python的购物比价api调用代码实例代码描述:基于Python的购物比价api调用代码实例代码平台:聚合数据#!/usr/bin/python#-*-coding:utf-8-*-importjson,urllibfromurllibimporturlencode#----------------------------------#商品比价调用示例代码-聚合数据#在线接口文档:#----------------------------------defmain():#配置您申请的APPKeyappkey="*********************"#(appkey,"GET")#(appkey,"GET")#(appkey,"GET")#查询支持的商城信息defrequest1(appkey,m="GET"):url=""params={"key":appkey,#应用APPKEY(应用详细页查询)}params=urlencode(params)ifm=="GET":f=("%s?%s"%(url,params))else:f=(url,params)content=()res=(content)ifres:error_code=res["error_code"]iferror_code==0:#成功请求printres["result"]else:print"%s:%s"%(res["error_code"],res["reason"])else:print"requestapierror"#比价简单查询接口defrequest2(appkey,m="GET"):url=""params={"keyword":"",#要查询关键字"key":appkey,#应用APPKEY(应用详细页查询)}params=urlencode(params)ifm=="GET":f=("%s?%s"%(url,params))else:f=(url,params)content=()res=(content)ifres:error_code=res["error_code"]iferror_code==0:#成功请求printres["result"]else:print"%s:%s"%(res["error_code"],res["reason"])else:print"requestapierror"#比价复杂查询接口defrequest3(appkey,m="GET"):url=""params={"keyword":"",#搜索关键字"key":appkey,#应用APPKEY(应用详细页查询)"Site":"",#商城编号,默认为0,即所有"PriceMi
基于python的购物比价api调用代码实例 来自淘豆网m.daumloan.com转载请标明出处.