Projet 2 - Utilisez les bases de Python pour l'analyse de marché
This script allows you to scrape the books.toscrape.com website.
There's 3 ways you can use the script :
- Scrape the entire website
- Scrape a specified category
- Scrape a specified product
It will save a csv file by category and the image of each product.
This project runs in python 3
Make a copy of this project on your hard drive
git clone https://github.com/friquette/OC_Projet_02.git
Go in the root project and create a virtual environment
cd OC_Projet_02
python -m venv env
Activate your virtual environment
- On windows
env\Scripts\activate.bat
- On Mac OS/Linux
source env/bin/activate
Install the packages
pip install -r requirements.txt
When you execute a script, a "csv" folder will be created in
the folder path you want.
You can use the script 3 different ways
-
Execute the script.py file with the folder path you want as argument
python booksToScrape.py <my_folder_path>
A folder for each category will be created in the "csv" folder. The .csv file and images associated will be created in each category folder.
-
Execute the scrapeCategory.py file with the folder path and the category url you want as arguments
python scrapeCategory.py <my_folder_path> <my_category_url>
A folder named after the category will be created in the "csv" folder. The .csv file and images associated will be created in the category folder.
-
Execute the scrapeBook.py file with the folder path and the product url you want as arguments
python scrapeBook.py <my_folder_path> <my_book_url>
The .csv file and image associated will be created in the "csv" folder.