feat: scrape blog.python.org and store in PostgreSQL - #140
Open
aashitha20 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR turns the existing sample script into a Python web scraper intended to collect posts from blog.python.org and persist them into a PostgreSQL table, packaged for local execution via Docker Compose.
Changes:
- Replaced the previous demo scraping logic with a multi-page blog scraper and PostgreSQL persistence (including deduping on URL).
- Added a PostgreSQL schema (
schema.sql) and inserts withON CONFLICT DO NOTHING. - Updated containerization to use
requirements.txt, and added a Postgres service + env-driven configuration in Docker Compose.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| web_scraping_sample.py | Implements scraping, parsing, and PostgreSQL insert logic (plus env configuration). |
| schema.sql | Defines the blog_posts table with a unique URL constraint for deduplication. |
| Dockerfile | Builds a runnable scraper image based on requirements.txt. |
| docker-compose.yaml | Adds PostgreSQL service + healthcheck and wires scraper env vars to the DB container. |
| .gitignore | Ignores .env, virtualenv, and Python bytecode artifacts. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+128
to
+130
| def main(): | ||
| logging.basicConfig(level=os.getenv("LOG_LEVEL", "INFO")) | ||
| posts = scrape_posts(BLOG_URL) |
Comment on lines
+107
to
+108
| with open("schema.sql", encoding="utf-8") as schema_file: | ||
| cursor.execute(schema_file.read()) |
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.
Workshop 1 Homework