Add Python blog scraper with PostgreSQL storage (Dockerized) - #137
Open
Lekhaaa-S wants to merge 1 commit into
Open
Add Python blog scraper with PostgreSQL storage (Dockerized)#137Lekhaaa-S wants to merge 1 commit into
Lekhaaa-S wants to merge 1 commit 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.
What this does
Scrapes blog posts from blog.python.org and stores them in a PostgreSQL
database, fully containerized with Docker.
Approach
/rss.xml) instead of scraping raw HTML.RSS gives clean, structured data (title, link, author, date,
description) without depending on the page's CSS/HTML structure,
which is more fragile and breaks if the site redesigns.
xml.etree.ElementTree.blogstable in PostgreSQL, with aUNIQUEconstraint on
urlandON CONFLICT ... DO UPDATE, so re-running thescraper updates existing rows instead of duplicating them.
Docker setup
Dockerfile: builds the Python environment, installingrequirements.txtbefore copying the rest of the source (for properlayer caching).
docker-compose.yaml: runs two services —psql-db(Postgres) andscraper(the Python script). Added ahealthcheckonpsql-dbsothe scraper waits until the database is actually ready before
connecting.
How to run
Verified
HTTP status: 200)