The code from here shows nicely how to extract economic data from https://www.investing.com/economic-calendar/. However, the code just scrapes the data from the current economic data table that is from today. There is a calendar icon where the timeframe can be set manually and past economic events can be viewed (highlighted red on the screenshot):
Is there a way to scrape the past econonomic event data? So far, I have not really an idea …
I’m not 100% sure if you are looking excactly for this BUT have you tried investpy? It is a great python module, that seems to do exactly what you are trying to achieve but with less pain.
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
and then use it as seen below (and also 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%
- trendet – Trend detection on stock time series data
- pyrtfolio – Python package to generate stock portfolios