Code Description: Python-based Equity data interface call Code instance
Associated data: Equity data
Interface Address: HTTPS://WWW.JUHE.CN/DOCS/API/ID/25
#!/usr/bin/python#-*-coding:utf-8-*-import json, urllibfrom urllib import urlencode#------------------------------- ---# Equity data Call Sample code-aggregate data # Online interface Documentation: http://www.juhe.cn/docs/25#----------------------------------def Main (): # Configure the Appkey Appkey = "*********************" #1 you requested. All open funds Request1 (Appkey, "get") #2. Stock Fund Request2 (Appkey, "get") #3. General Bond fund Request3 (Appkey, "get") #4. Currency Fund Request4 (Appkey, "get") #5. Closed-type fund REQUEST5 (Appkey, "get") #6. Innovation They trade Request6 (APPK EY, "get") #7. LOF request7 (Appkey, "get") #8. ETF request8 (Appkey, "get") #9. QDII Request9 (Appkey, "get") #全部开放基金def Reque St1 (Appkey, m= "GET"): url = "Http://web.juhe.cn:8080/fund/netdata/all" params = {"Key": Appkey, #APPKEY值} params = UrlEncode (params) if m = = "GET": F = Urllib.urlopen ("%s?%s"% (URL, params)) Else:f = Urllib.urlopen (URL, param s) 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" #股票型基金def Request2 (Appkey, m= "GET" ): url = "Http://web.juhe.cn:8080/fund/netdata/stock" params = {"Key": Appkey, #APPKEY值} params = UrlEncode (par AMS) 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" #普通债券型基 Gold def request3 (Appkey, m= "GET"): url = "Http://web.juhe.cn:8080/fund/netdata/bond" params = {"Key": Appkey, #APPKEY值 } params = UrlEncode (params) if m = = "GET": F = Urllib.urlopen ("%s?%s"% (URL, params)) Else:f = Urllib.urlope N (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" #货币 Type Fund def request4 (Appkey, m= "GET"): url = "Http://web.juhe.cn:8080/fund/netdata/monet" params = {"Key": Appkey, #APPK EY value} params = UrlEncode (params) if m = = "GET": F = Urllib.urlopen ("%s?%s"% (URL, params)) Else:f = Urllib.url Open (URL, params) content = F.read () res = json.loads (content) If Res:error_code = res["Error_code"] if Error_c Ode = = 0: #成功请求 print res["result"] else:print "%s:%s"% (res["error_code"],res["Reason"]) else:pr int "Request API Error" #封闭型基金def REQUEST5 (Appkey, m= "GET"): url = "Http://web.juhe.cn:8080/fund/netdata/close" params = {"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" #创新封基def REQUEST6 (Appkey, m= "GET"): url = "Http://web.juhe.cn:8080/fund/netdata/innov" params = {"Key": Appkey, #APPKEY值} params = UrlEncode (params) if m = = "GET": F = Urllib.urlopen ("%s?%s"% (URL, para ms)) Else:f = Urllib.urlopen (URL, params) content = F.read () res = json.loads (content) If Res:error_code = re s["Error_code"] if Error_code = = 0: #成功请求 print res["result"] else:print "%s:%s"% (res["Error_code" ],res["Reason"]) else:print "Request API Error" #LOFdef request7 (Appkey, m= "GET"): url = "Http://web.juhe.cn:8080/fu Nd/netdata/lof "params = {" Key ": Appkey, #APPKEY值} params = UrlEncode (params) if m = =" GET ": F = urllib.urlop En ("%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" #ETFdef REQUEST8 (Appkey, m= "GET"): url = "Http://web.juhe.cn:8080/fun D/NETDATA/ETF "params = {" Key ": Appkey, #APPKEY值} params = UrlEncode (params) if m = =" GET ": F = urllib.urlope N ("%s?%s"% (URL, params)) Else:f = Urllib.urlopen (URL, params) content = F.read () res = json.loads (content) if R Es: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 "#QDIIdef Request9 (Appkey, m=" GET "): url =" Htt P://web.juhe.cn:8080/fund/netdata/qdii "params = {" Key ": Appkey, #APPKEY值} params = UrlEncode (params) if m = =" G ET ": F = Urllib.urlopen ("%s?%s "% (URL, params)) Else:f = Urllib.urlopen (URL, params) content = F.read () res = Json.loads (content) ifRes: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 ()