This repository has a module that allows the scrapping of the Peruvian Central of Reserve (BCRP) Statistics Database.
The repository contains the following folders:
src
: Contains the.py
files where the functions are defined, specifically under thebcrp_webscrapper
subdirectory.test
: Includes example usage and tests for the functions.dist
: Contains the distribution packages, such as.tar.gz
and.whl
files, for different versions of the project.build
: Holds build-related files, including intermediate files and directories used during the packaging process.
You need to make sure you have installed the following modules.
- Requests
- Unidecode
- Selenium
- Webdriver_manager
- openpyxl
pip install requests
pip install unidecode
pip install selenium
pip install webdriver_manager
pip install openpyxl
pip install more-itertools
pip install bcrp-webscrapper
The module defines the following main functions:
This function provides a basic searcher for the BCRP Database website. We provide the name of the series and the frequency we want and search for the data available. It returns a dataframe with all series that match our input.
This function scraps series from the BCRP Database and gives us a dataframe with the series.
This function graphs series from the BCRP Database.
This function scraps series from the BCRP Database and downloads the image in the given format (png, jpg, pdf).
- Example 1
from bcrp_webscrapper import *
var = "Expectativas"
freq = "Mensual"
print(bcrp.bcrp_search( var , freq))
var2 = "PBI"
print(bcrp.bcrp_search( var2 ))
- Example 2
from bcrp_webscrapper import *
codes = ['PD04637PD', 'PD04638PD']
start_date = '2012-03-12'
end_date = '2022-05-30'
freq = 'Diario'
bcrp.bcrp_dataframe( codes , start_date , end_date , freq)
- Example 3
from bcrp_webscrapper import *
codes = ['PD09919MA', 'PD09920MA']
start_date = '2015'
end_date = '2022'
bcrp.bcrp_graph( codes , start_date , end_date )
For more examples, please refer to the the test folder.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
- Email: estcab00@gmail.com