- Python 3.*
- Docker and docker-compose is preferred but optional.
Clone the repository
git clone https://github.com/VVNoodle/Investing.com_Scraper.git
You can choose to run using Docker or manually.
build docker image and run it by executing
docker-compose up --build
docker automatically:
- installs dependencies
- fetches data
- tests the flask server
- runs the flask server
install dependencies. you can choose to create a virtual environment if preferred.
pip install -r requirements.txt
fetch data
python3 fetch_data.py
After finish executing, there will be 2 .csv files: gold.csv
and silver.csv
. They consist the corresponding Date
and Price
features as per exercise specs.
Next thing to do is to run the flask server
python3 service.py
- URL
/commodity?start_date=2019-04-17&end_date=2019-05-01&commodity_type=gold
- Method:
GET
- URL Params
Required:
start_date=[datetime]
end_date=[datetime]
commodity_type=[string]
-
Success Response:
-
Code: 200
Content: JSON Response
{
data : {
"2017-05-10": 1253.06,
"2017-05-11": 1280.46,
"2017-05-12": 1278.21
},
mean: 1270.57,
"variance": 231.39
}
-
Error Response:
-
Code: 422 Unprocessable Entity
Content: { error : "valid url, but not all required parameters are entered (start_date, end_date, commodity_type)" }
OR
-
Code: 404 URL not found
-
Sample Call:
http://127.0.0.1:8080/commodity?start_date=2019-04-17&end_date=2019-05-01&commodity_type=gold
-
Pandas - data structures and data analysis tools
-
BeautifulSoup - Web Scraping
- Egan Bisma