This project fethces information from cars.com and provides it through an API.
Project consisted of three main stages:
- Writing web scrapper for fething information from cars.com
- Saving fetched data into mySQL
- Provide API
First two is done by scripts in api/utils
, while providing API utilizes Django Rest Framework.
To initialize dataset,
first run python manage.py shell
in root directory. Then in the shell run following lines,
from api.utils.write_database import main
main()
After initialization you should do the following to run server,
python manage.py runserver
Now you can access API with,
http://localhost:8000/api
or make some filtering,
http://localhost:8000/api/?ext_color=black&transmission=automatic&&brand=BMW&&year=2012
which results in following,
[
{
"brand": "BMW",
"price": "17400",
"year": "2012",
"model": "750 i xDrive",
"ext_color": "black",
"int_color": "black",
"transmission": "automatic",
"contact": "(404) 935-6893"
}
]
Note:
Don't forget to edit mySQL configurations in settings.py
. They are currently configured for my local computer.
- Write django custom command to more elegant initilazation. Current one requires opening django shell.
- Configure Docker.