This article mainly introduces the Python net worth data interface call examples to share the relevant information, friends can refer to the following code Description: Python-based net worth data interface call code example
Associated data: net worth data
Interface address: https://www.juhe.cn/docs/api/id/25
#! /Usr/bin/python #-*-coding: UTF-8-*-import json, urllibfrom urllib import urlencode # ---------------------------- # sample code for calling net worth data-aggregate data # online interface documentation: http://www.juhe.cn/docs/25#----------------------------------def Main (): # configure the APPKey appkey = "*************************" #1. all open funds request1 (appkey, "GET") #2. equity Fund request2 (appkey, "GET") #3. request3 (appkey, "GET") #4. monetary Fund request4 (appkey, "GET") #5. closed Fund request5 (appkey, "GET") #6. innovation block request6 (appkey, "GET") # 7.LOF request7 (appkey, "GET") # 8.ETF request8 (appkey, "GET") #9. QDII request9 (appkey, "GET") # all open funds def request1 (appkey, m = "GET"): url =" http://web.juhe.cn:8080/fund/netdata/all "Params = {" key ": appkey, # APPKEY value} 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: # successful request print res ["result"] else: print "% s: % s "% (res [" error_code "], res [" reason "]) else: print" request api error "# stock fund def request2 (appkey, m = "GET"): url =" http://web.juhe.cn:8080/fund/netdata/stock "Params = {" key ": appkey, # APPKEY value} 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: # successful request print res ["result"] else: print "% s: % s "% (res [" error_code "], res [" reason "]) else: print" request api error "# def request3 (appkey, m = "GET"): url =" http://web.juhe.cn:8080/fund/netdata/bond "Params = {" key ": appkey, # APPKEY value} 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: # successful request print res ["result"] else: print "% s: % s "% (res [" error_code "], res [" reason "]) else: print" request api error "# Monetary Fund def request4 (appkey, m = "GET"): url =" http://web.juhe.cn:8080/fund/netdata/monet "Params = {" key ": appkey, # APPKEY value} 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: # successful request print res ["result"] else: print "% s: % s "% (res [" error_code "], res [" reason "]) else: print" request api error "# def request5 (appkey, m = "GET"): url =" http://web.juhe.cn:8080/fund/netdata/close "Params = {" key ": appkey, # APPKEY value} 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: # successful request print res ["result"] else: print "% s: % s "% (res [" error_code "], res [" reason "]) else: print" request api error "# innovation block def request6 (appkey, m = "GET"): url =" http://web.juhe.cn:8080/fund/netdata/innov "Params = {" key ": appkey, # APPKEY value} 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: # successful request 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/fund/netdata/lof "Params = {" key ": appkey, # APPKEY value} 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: # successful request 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/fund/netdata/etf "Params = {" key ": appkey, # APPKEY value} 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: # successful request print res ["result"] else: print "% s: % s "% (res [" error_code "], res [" reason "]) else: print" request api error "# QDIIdef request9 (appkey, m =" GET "): url =" http://web.juhe.cn:8080/fund/netdata/qdii "Params = {" key ": appkey, # APPKEY value} 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: # successful request print res ["result"] else: print "% s: % s "% (res [" error_code "], res [" reason "]) else: print "request api error" if _ name _ = '_ main _': main ()