首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过Python从investing.com下载AEX未来的日内数据

通过Python从investing.com下载AEX未来的日内数据
EN

Stack Overflow用户
提问于 2022-01-26 15:52:45
回答 1查看 368关注 0票数 0

我的目标是在Python中为AEX的未来提供1分钟的蜡烛数据。首先,对历史数据集进行回溯测试,然后是实时数据。

我试过使用InvestPy,但这并没有给出任何一天内的历史利率。AEX的未来也不能在雅虎金融,这将使它非常容易。

因此,我正在研究从Investing.com网站上抓取它的可能性。我看到了一些这样做的帖子,this code似乎很有帮助。

然而,我不能让它为AEX期货公司工作。

这是那个操作系统的代码。我不知道从哪里可以得到'URL‘部分。我在Chrome上的“检查页面”然后“网络”选项卡中找到了下面的URL。它确实给了我一些关于AEX的数据,但是没有引号或蜡烛之类的。

我已经更新了‘推荐人’部分的网页,我想要的数据。

代码语言:javascript
复制
import json
import datetime
import requests 
from bs4 import BeautifulSoup

url = 'https://tvc4.investing.com/53ec64967b82eb6e28595146e26b6579/1643213764/1/1/8/symbols?symbol=N25'
headers = {
    'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0',
    'X-Requested-With': 'XMLHttpRequest',
    'Referer': 'https://nl.investing.com/indices/netherlands-25-futures'}
data = requests.get(url, headers=headers).json()

# uncomment this to print all data:
# print( json.dumps(data, indent=4) )

for candle in data['candles']:
    t = datetime.datetime.fromtimestamp(candle[0] // 1000)
    print('{!s:<20} {:<10} {:<10} {:<10}'.format(t, *candle[1:]))
EN

回答 1

Stack Overflow用户

发布于 2022-03-12 11:05:33

这里的解决方案是:阅读我解释的初始注释,您也可以在这里找到所有的ID

https://sites.google.com/site/amibrokerplugins/investing_com_realtime_amibroker_data_plugin

按下botton“只允许SymbolInfo文件”

enter code here导入json导入日期时间从bs4 BeautifulSoup导入请求

代码语言:javascript
复制
# https://it.investing.com/indices/netherlands-25-futures
# ID for the future = 8878
# to find you must search : setTargeting("pair_id",
# and after the comma you will find "8878"
# then change the id in the url


url = 'https://it.investing.com/common/modules/js_instrument_chart/api/data.php?pair_id=8878&pair_id_for_news=8888&chart_type=area&pair_interval=300&candle_count=120&events=yes&volume_series=yes&period='
headers = {
    'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0',
    'X-Requested-With': 'XMLHttpRequest',
    'Referer': 'https://it.investing.com/indices/netherlands-25-futures'}
data = requests.get(url, headers=headers).json()

# uncomment this to print all data:
# print( json.dumps(data, indent=4) )

print("##################################################################")
#print("Inizio candele" )
for candle in data['candles']:
    t = datetime.datetime.fromtimestamp(candle[0] // 1000)
    print('{!s:<20} {:<10} {:<10} {:<10}'.format(t, *candle[1:]))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70866321

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档