feat(workshop1): implement python blog scraper with postgresql and do… - #131
Open
arbn2005 wants to merge 2 commits into
Open
feat(workshop1): implement python blog scraper with postgresql and do…#131arbn2005 wants to merge 2 commits into
arbn2005 wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)scrape_python_blogs()usingrequestsandBeautifulSoupto extract blog post titles, authors, published dates, and URLs.get_db_connection()with automatic retries for database container startup.init_db()andsave_posts_to_db()usingINSERT ... ON CONFLICT (post_link) DO UPDATEto ensure idempotent database insertions.rich.2. Dependencies & Configuration (
requirements.txt&.gitignore)requirements.txtwithpsycopg2-binary>=2.9.10,beautifulsoup4,requests,html5lib, andrich..gitignoreto prevent committing virtual environment directories (venv/) and cache files.3. Containerization (
Dockerfile&docker-compose.yaml)Dockerfilebased onpython:3.10-slim.docker-compose.yamlwith: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: