📚 Amazon Book Scraper
A Python automation tool that extracts book titles from Amazon product pages using Selenium. This scraper reads links from a file, handles pop-ups, saves extracted titles into an output file, and logs the entire process.
✨ Features
🔗 Open Amazon book product pages automatically
⚡ Handle common pop-ups (e.g., "Continue" button)
📝 Extract book titles and save them to output/metadata.txt
🛠️ Detailed logging saved in logs/automation.log
🎲 Randomized request delays to reduce blocking risk
📂 Clean, extensible project structure
📂 Project Structure amazon-book-scraper/ ├── src/ │ ├── init.py # Makes src a package │ ├── amazon_book_scraper.py # AmazonScraper class (core logic) │ └── main.py # Script to run the scraper │ ├── books/ │ └── links.txt # Input file: Amazon product links │ ├── output/ │ └── metadata.txt # Output: extracted book titles │ ├── logs/ │ └── automation.log # Log file (auto-created) │ │ ├── requirements.txt # Project dependencies ├── .gitignore # Files/folders ignored by Git └── README.md # Documentation
🚀 Installation
Clone the repository
git clone https://github.com/nothingness-dev/AmazonBookScraper.git cd AmazonBookScraper
Install dependencies
pip install -r requirements.txt
Add Amazon book product links (one per line) into books/links.txt:
https://www.amazon.com/dp/B08XJG8MQM https://www.amazon.com/dp/B07ZZWZG8Z
Run the scraper:
python src/main.py
Results:
Extracted book titles → output/metadata.txt
Logs (success/errors) → logs/automation.log
📝 Example Code from src.amazon_bookscraper import AmazonScraper import random, time
bot = AmazonScraper()
with open("books/links.txt", "r") as datas: links = datas.readlines()
for link in links: bot.open(link.strip()) time.sleep(random.uniform(2, 5))
bot.close()
Requires Google Chrome installed
Uses webdriver-manager to handle ChromeDriver automatically
Random delays (2–5 seconds) are included to reduce the risk of being blocked by Amazon
📜 License
This project is licensed under the MIT License.