#!/usr/bin/python#-*-coding:utf-8-*-import json, urllibfrom urllib import UrlEncode #------------------------------- ---# Mobile Unicom base Station invocation sample code-aggregated data # Online interface Documentation: http://www.juhe.cn/docs/8#----------------------------------def main (): #配置您申请的APPK EY appkey = "*********************" #1. Base Station location Request1 (Appkey, "get") #基站定位def Request1 (Appkey, m= "get"): URL = "Http://v.juhe.cn/cell/get" params = {"<font color=red>mnc</font>": "", #<font color=red> move Base Station: 0 Unicom Base Station: 1 Default:0</font> "Lac": "", #小区号 "cell": ", #基站号" hex ":", #进制类型, 16 or 10, default: 10 "Dtype": ", #返回的数据格式: Json/xml/jsonp" callback ":", #当选择jsonp格式时必须传递 "key": Appkey, #APPKEY} params = UrlEncode (params) if m = = "GET": F = Urllib.urlopen ("%s?%s"% (URL, params)) Else:f = Urllib. Urlopen (URL, params) content = F.read () res = json.loads (content) If Res:error_code = res["Error_code"] If Error_code = = 0: #成功请求 print res["result"] else:print "%s:%s"% (res["error_code"],res["Reason"]) Else:print "Request API Error" if __name__ = = ' __main__ ': Main ()