Skip to content

arabind-meher/Amazon-Web-Scraper-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ Amazon Web Scraper API

This project is a FastAPI-based web API that scrapes product data from Amazon using Selenium and stores it in a MySQL database. It allows users to add, update, retrieve, and delete product records via HTTP endpoints.

⚠️ Note: This project is for educational purposes only. Frequent scraping of Amazon may violate their Terms of Service.


πŸš€ Features

  • Scrape Amazon product details using a provided product URL.
  • Extracted fields include:
    • Product title
    • Price
    • Image URL
  • Store product data in a MySQL database.
  • Perform CRUD operations via RESTful endpoints:
    • Add new product
    • Fetch all or specific product
    • Update individual or all product prices
    • Delete product by ID

πŸ“ Project Structure

Amazon-Web-Scraper-API/
β”‚
β”œβ”€β”€ amazon/
β”‚   └── products.py          # Core logic for scraping product data using Selenium
β”‚
β”œβ”€β”€ app/
β”‚   └── main.py              # FastAPI application with all API routes
β”‚
β”œβ”€β”€ database/
β”‚   β”œβ”€β”€ models.py            # SQLAlchemy models for Products table
β”‚   └── schemas.py           # Database connection and session logic
β”‚
β”œβ”€β”€ .gitignore
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
└── credentials.env          # Environment variables (ignored in git)

βš™οΈ Requirements

Install dependencies using pip:

pip install -r requirements.txt

Ensure you have MySQL running and a database created. Store your credentials in a credentials.env file like this:

_USERNAME=your_username
_PASSWORD=your_password
_HOST=localhost
_PORT=3306
_DATABASE=your_database_name

▢️ How to Run

  1. Create the database schema:

    from database.models import create_all
    create_all()
  2. Start the FastAPI server:

    uvicorn app.main:app --reload
  3. Use the API endpoints:

    • Add product by scraping:
      POST /products/add?url={amazon_product_url}&target={target_price}
      
    • Fetch all products:
      GET /products
      
    • Fetch specific product:
      GET /products/{product_id}
      
    • Update all products:
      PUT /products/update
      
    • Update specific product:
      PUT /products/update/{product_id}
      
    • Delete a product:
      DELETE /products/delete/{product_id}
      

πŸ›  Technologies Used

  • Python
  • FastAPI
  • Selenium
  • SQLAlchemy
  • MySQL
  • Uvicorn
  • Python-dotenv

πŸ‘¨β€πŸ’» Author

Arabind Meher
GitHub β€’ LinkedIn

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages