Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Web-Scraping/Configurable-Scraper/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"url": "https://quotes.toscrape.com",
"tag": "span",
"class": "text"
}
14 changes: 14 additions & 0 deletions Web-Scraping/Configurable-Scraper/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Configurable Web Scraper

This script allows scraping any website using a JSON configuration file.

## Features
- Config-driven scraping
- Reusable for multiple websites
- Simple and beginner-friendly

## How to Use

1. Edit config.json
2. Run:
python scraper.py
2 changes: 2 additions & 0 deletions Web-Scraping/Configurable-Scraper/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
requests
beautifulsoup4
21 changes: 21 additions & 0 deletions Web-Scraping/Configurable-Scraper/scrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import requests
from bs4 import BeautifulSoup
import json

# Load config
with open("config.json") as f:
config = json.load(f)

url = config["url"]
tag = config["tag"]
class_name = config["class"]

response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")

elements = soup.find_all(tag, class_=class_name)

print(f"\nScraping from: {url}\n")

for i, el in enumerate(elements, 1):
print(f"{i}. {el.text.strip()}")