Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 1.98 KB

README.md

File metadata and controls

62 lines (46 loc) · 1.98 KB

OC_Projet_02

Projet 2 - Utilisez les bases de Python pour l'analyse de marché

What is the script for?

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.

Set up the project

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

How to use it

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

  • Scrape the entire website:

    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.

  • Scrape a specified category

    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.

  • Scrape a specified product

    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.