从 investing.com 抓取历史经济数据

Scrape historical economic data from investing.com

来自 here shows nicely how to extract economic data from https://www.investing.com/economic-calendar/ 的代码。但是,该代码只是从今天的当前经济数据 table 中抓取数据。有一个日历图标,可以手动设置时间范围,可以查看过去的经济事件(屏幕截图中以红色突出显示):

有没有办法抓取过去的经济事件数据?到目前为止,我还没有真正的想法...

我不是 100% 确定你是否正在寻找这个但是 你试过了吗 investpy? 它是一个很棒的 python 模块,它似乎可以完全满足您的要求,但痛苦更少。

investpy is a Python package to retrieve data from Investing.com... investpy allows the user to download both recent and historical data from all the financial products indexed at Investing.com. It includes data from all over the world, from countries such as United States, France, India, Spain, Russia, or Germany, amongst many others.

pip install investpy

然后如下所示使用它 (以及 here:

import investpy

data = investpy.economic_calendar(
    from_date='12/09/2021',
    to_date  ='13/09/2021'
)
print(data.head())
       id        date   time                  zone currency importance                                     event  actual forecast previous
0  436810  12/09/2021  09:59  united arab emirates      AED        low         Private Sector Loans (YoY)  (Jul)  -1.80%     None   -1.20%
1  435581  13/09/2021  01:45           new zealand      NZD        low                          FPI (MoM)  (Aug)    0.3%     None     1.3%
2  435584  13/09/2021  02:50                 japan      JPY     medium  BSI Large Manufacturing Conditions  (Q3)     7.0     None     -1.4
3  435583  13/09/2021  02:50                 japan      JPY        low                          PPI (YoY)  (Aug)    5.5%     5.6%     5.6%
4  435582  13/09/2021  02:50                 japan      JPY        low                          PPI (MoM)  (Aug)    0.0%     0.2%     1.1%

Related projects: