iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >Python的净值数据接口调用示例分享
  • 800
分享到

Python的净值数据接口调用示例分享

净值示例接口 2022-06-04 19:06:22 800人浏览 独家记忆

Python 官方文档:入门教程 => 点击学习

摘要

代码描述:基于python的净值数据接口调用代码实例 关联数据:净值数据 接口地址:https://www.juhe.cn/docs/api/id/25 #!/usr/bin/Python # -*-

代码描述:基于python的净值数据接口调用代码实例
关联数据:净值数据
接口地址:https://www.juhe.cn/docs/api/id/25


#!/usr/bin/Python
# -*- coding: utf-8 -*-
import JSON, urllib
from urllib import urlencode

#----------------------------------
# 净值数据调用示例代码 - 聚合数据
# 在线接口文档:Http://www.juhe.cn/docs/25
#----------------------------------

def main():

  #配置您申请的APPKey
  appkey = "*********************"

  #1.全部开放基金
  request1(appkey,"GET")

  #2.股票型基金
  request2(appkey,"GET")

  #3.普通债券型基金
  request3(appkey,"GET")

  #4.货币型基金
  request4(appkey,"GET")

  #5.封闭型基金
  request5(appkey,"GET")
 
  #6.创新封基
  request6(appkey,"GET")

  #7.LOF
  request7(appkey,"GET")

  #8.ETF
  request8(appkey,"GET")

  #9.QDII
  request9(appkey,"GET")

#全部开放基金
def request1(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, 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 request2(appkey, m="GET"):
  url = "http://web.juhe.cn:8080/fund/netdata/stock"
  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 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.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 request4(appkey, m="GET"):
  url = "http://web.juhe.cn:8080/fund/netdata/monet"
  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 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, 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"
 
#LOF
def request7(appkey, m="GET"):
  url = "http://web.juhe.cn:8080/fund/netdata/lof"
  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"
 
#ETF
def request8(appkey, m="GET"):
  url = "http://web.juhe.cn:8080/fund/netdata/etf"
  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"
 
#QDII
def request9(appkey, m="GET"):
  url = "http://web.juhe.cn:8080/fund/netdata/qdii"
  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"

if __name__ == '__main__':
  main()

--结束END--

本文标题: Python的净值数据接口调用示例分享

本文链接: https://www.lsjlt.com/news/15165.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • 基于聚合数据的短信API接口调用示例-Python版
    一、申请接口 通过https://www.juhe.cn/docs/api/id/54自助申请开通短信API,获得接口请求Key。(目前接口暂只支持企业类用户使用) 申请后,在个人中心提交短信模板,聚合官方已经提供了多个常用模板,可以快捷申...
    99+
    2024-04-02
  • 基于聚合数据的老黄历接口调用示例-Python版
    前期准备 接口申请,申请地址—“聚合数据”官网:https://www.juhe.cn/docs/api/id/65 你可以在个人中心 ➡️ 数据中心 ➡️ 我的API 模块看到此接口的调用凭证请求key 接口说明 免费使用,根据会员...
    99+
    2024-04-02
  • python 调用接口造数据
    #!/usr/bin/python #!-*-coding:utf-8 -*- import MySQLdb import urllib2 impo...
    99+
    2023-01-31
    接口 数据 python
  • Python封装SNMP调用接口的示例代码
    PySNMP 是一个纯粹用Python实现的SNMP,用PySNMP的最抽象的API为One-line Applications,其中有两类API:同步的和非同步的,都在模块pysn...
    99+
    2024-04-02
  • 基于Java接口回调的示例分析
    基于Java接口回调的示例分析,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。Java接口回调产生接口回调的场景在现实生活中,产生接口回调的场景很简单,比如我主动叫你帮我做一件事...
    99+
    2023-06-22
  • 大数据索引在ASP接口中的应用案例分享。
    随着大数据时代的到来,数据量越来越大,如何高效地存储和检索数据成为了亟待解决的问题。大数据索引技术就应运而生,它能够快速地找到数据,提高了数据检索的效率。在ASP接口中,大数据索引技术也有着广泛的应用。本文将分享一个大数据索引在ASP接口中...
    99+
    2023-10-04
    接口 大数据 索引
  • 基于node.js的聚合数据的短信API接口调用示例
    前期准备 根据运营商的要求,目前此接口只对实名认证的企业用户开放使用,所以在使用之前请确保您是实名认证的企业用户 申请接口,你可以在个人中心 ➡️ 数据中心 ➡️ 我的API 模块看到此接口的调用凭证请求key 接口申请开通入口...
    99+
    2024-04-02
  • 微信域名检测接口调用演示的示例分析
    这篇文章给大家分享的是有关微信域名检测接口调用演示的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。微信域名检测接口是腾讯官方发布的api接口,调用检测接口即可返回域名在微...
    99+
    2024-04-02
  • 基于聚合数据的老黄历接口调用示例-PHP版
    前期准备 接口申请,申请地址—“聚合数据”官网:https://www.juhe.cn/docs/api/id/65 你可以在个人中心 ➡️ 数据中心 ➡️ 我的API 模块看到此接口的调用凭证请求key 接口说明 免费使用,根据会员...
    99+
    2024-04-02
  • 基于聚合数据的老黄历接口调用示例-JAVA版
    本文介绍聚合数据的老黄历接口的使用 依赖 <dependency> <groupId>net.sf.json-lib</groupId> ...
    99+
    2024-04-02
  • ajax请求后台接口数据与返回值处理js的示例分析
    这篇文章给大家分享的是有关ajax请求后台接口数据与返回值处理js的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。ajax的代码,用的是jquery的 ajax:$.aj...
    99+
    2024-04-02
  • python怎么调用接口获取数据
    要调用接口获取数据,可以使用Python中的requests库。下面是一个简单的示例:```pythonimport request...
    99+
    2023-08-30
    python
  • python链式函数调用的示例分析
    小编给大家分享一下python链式函数调用的示例分析,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!链式函数调用你可以在一行代码内调用多个函数。def a...
    99+
    2023-06-27
  • 基于聚合数据的短信API接口(54)调用示例-Java版
    前期准备 根据运营商的要求,目前此接口只对实名认证的企业用户开放使用,所以在使用之前请确保您是实名认证的企业用户 申请接口,你可以在个人中心 ➡️ 数据中心 ➡️ 我的API 模块看到此接口的调用凭证请求key 购买数据的请求次...
    99+
    2024-04-02
  • 基于聚合数据的笑话大全接口调用示例-PHP版
    前期准备 申请接口,你可以在个人中心 ➡️ 数据中心 ➡️ 我的API 模块看到此接口的调用凭证请求key 请仔细阅读官网的接口文档,这是聚合数据与开发者的约定,它将有助于您对接口业务的理解,从而顺利地开展开发工作 1.随机获取笑话接口...
    99+
    2024-04-02
  • 基于聚合数据的笑话大全接口调用示例-JAVA版
    接口地址 接口地址 前言 本文主要介绍笑话大全接口的调用示例 依赖 <dependency> <groupId>net.sf.json-lib</groupId> ...
    99+
    2024-04-02
  • 基于聚合数据的短信API接口(54)调用示例-PHP版
    前期准备 根据运营商的要求,目前此接口只对实名认证的企业用户开放使用,所以在使用之前请确保您是实名认证的企业用户 申请接口,你可以在个人中心 ➡️ 数据中心 ➡️ 我的API 模块看到此接口的调用凭证请求key 购买数据的请求次...
    99+
    2024-04-02
  • golang调用c实现的dll接口细节分享
    目的 本篇文章主要介绍golang在调用c实现的dll时,具体的一些方式。比如值传递、参数传递、指针等等的一些使用。 一、dll的代码 c实现的dll代码: hello.h #i...
    99+
    2024-04-02
  • HTML5通用接口的示例分析
    这篇文章将为大家详细讲解有关HTML5通用接口的示例分析,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。1.先说几个基本类型: DOMString, boolean, lo...
    99+
    2024-04-02
  • 分享四个python接口常用封装函数
    目录1.封装上传图片的函数2. 封装车牌号的函数3. 封装生成UUid 函数4. 封装连接数据库的函数前言: 又到每日分享Python小技巧的时光了,今天给大家分享的是Python接...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作