金融数据,股票数据,虚拟货币,量化投资,学习量化
即将上线
即将上线
即将上线
即将上线
即将上线
即将上线
即将上线
即将上线
即将上线
即将上线
即将上线
即将上线
订购预测者网推送数据服务后,推送数据会在每天盘后发送到您的邮箱。此外,我们也提供了数据接口,让您可以写程序自动更新数据,不用每天从邮箱中下载数据。
该链接返回数据的下载地址。有如下几种情况:
Python3只需要更改一下urllib的库引用即可。
# encoding: utf-8 """ # API PYTHON DEMO 基于API V1的自动下载示例代码 使用前需去[https://www.yucezhe.com/user/home](https://www.yucezhe.com/user/home)配置API KEY; 使用时需配置注册邮箱,默认下载地址为程序同目录; Copyright © 2011-2017 yucezhe.com, All rights reserved. """ from urllib import urlretrieve, urlencode from urllib2 import urlopen # from urllib.request import urlopen, urlretrieve, urlencode # used in python3 API_URL = 'https://yucezhe.com/api/v1/data/today' # ****************************config*************************************** # EMAIL = 'contact@yucezhe.com' # 购买数据时候使用的邮箱地址 API_KEY = 'THIS IS YOUR API KEY' # 于页面配置的API KEY # **************************config_end************************************* # def get_today(product_name, local_file_name): """ :param product_name: the product name, get it from the url of the product homepage :param local_file_name: the local file name to save as :return: the download url after file saved """ params = { 'name': product_name, 'email': EMAIL, 'key': API_KEY } params_str = urlencode(params) response = urlopen('%s?%s' % (API_URL, params_str)) data_download_url = response.read() if 'data.yucezhe.com' in data_download_url: print('[URL GET]:', data_download_url) urlretrieve(data_download_url, local_file_name) return data_download_url else: print(data_download_url) return None def get_today_auto(product_name, local_file_name): """ this function will auto wait if the data is not ready and auto stop when download finished :param product_name: equivalent to 'get_today' :param local_file_name: equivalent to 'get_today' :return: nothing """ _u = get_today(product_name, local_file_name) import time while _u is None: print '[auto run]: data is not ready, retry in 30s' time.sleep(30) _u = get_today(product_name, local_file_name) get_today_auto('trading-data-push', 'trading-data-push.zip')