Skip to content

feat(workshop1): implement python blog scraper with postgresql and do… - #131

Open
arbn2005 wants to merge 2 commits into
UniCourt:mainfrom
arbn2005:solution-python-blog-scraper
Open

feat(workshop1): implement python blog scraper with postgresql and do…#131
arbn2005 wants to merge 2 commits into
UniCourt:mainfrom
arbn2005:solution-python-blog-scraper

Conversation

@arbn2005

Copy link
Copy Markdown

Summary

Completes the Workshop 1 Homework by scraping blog posts from Python Blogs, storing them into a PostgreSQL database, setting up dependency management, and containerizing the application using Docker Compose.


Proposed Changes

1. Application & Scraping Logic (scrap.py & web_scraping_sample.py)

  • Implemented scrape_python_blogs() using requests and BeautifulSoup to extract blog post titles, authors, published dates, and URLs.
  • Created get_db_connection() with automatic retries for database container startup.
  • Implemented init_db() and save_posts_to_db() using INSERT ... ON CONFLICT (post_link) DO UPDATE to ensure idempotent database insertions.
  • Added clean borderless terminal TUI output using rich.

2. Dependencies & Configuration (requirements.txt & .gitignore)

  • Updated requirements.txt with psycopg2-binary>=2.9.10, beautifulsoup4, requests, html5lib, and rich.
  • Added .gitignore to prevent committing virtual environment directories (venv/) and cache files.

3. Containerization (Dockerfile & docker-compose.yaml)

  • Updated Dockerfile based on python:3.10-slim.
  • Configured docker-compose.yaml with:
    • psql-db: PostgreSQL 14 database service with health checks.
    • python_service: Scraper application service dependent on PostgreSQL readiness.

Verification & Output Evidence

Executed docker compose up --rm python_service:

Screenshot 2026-08-26 at 1 55 00 AM Screenshot 2026-08-26 at 1 55 30 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant