A beginner-friendly, modular Python project that:
- Scrapes any webpage
- Cleans the raw text
- Answers your questions about the page using AI (RAG)
webscraping_rag_project/
│
├── config.py ← Settings and env loading (API key from `.env` or Streamlit secrets)
├── app.py ← Streamlit UI (main way to run the app)
├── pipeline.py ← Same flow as a Python class (for scripts / learning)
├── storage.py ← Saves FAISS index + metadata under `knowledge_bases/`
│
├── scraper/
│ ├── __init__.py
│ └── web_scraper.py ← Downloads webpages
│
├── cleaner/
│ ├── __init__.py
│ └── text_cleaner.py ← Cleans and splits text into chunks
│
├── rag/
│ ├── __init__.py
│ └── rag_system.py ← Builds the AI Q&A system
│
├── requirements.txt ← All packages needed
└── .env ← Create this locally: `GROQ_API_KEY=...` (not committed)
pip install -r requirements.txtCreate a .env file in the project folder (same directory as config.py):
GROQ_API_KEY=your_key_hereGet a free key at https://console.groq.com
On Streamlit Cloud, use App secrets or .streamlit/secrets.toml with GROQ_API_KEY instead.
streamlit run app.pyOpens at http://localhost:8501
Import Pipeline from pipeline.py and call run_all() / ask() from your own script (see docstrings in that file).
| Concept | What it means |
|---|---|
| Scraping | Downloading a webpage and pulling out the text |
| Cleaning | Removing junk HTML, menus, footers, extra whitespace |
| Chunking | Splitting long text into small pieces the AI can read |
| Embeddings | Converting text to numbers so AI can search it |
| FAISS | A fast database that stores and searches embeddings |
| RAG | AI reads your scraped page, then answers questions about it |
URL → scraper → raw text → cleaner → clean chunks → RAG → answers