Skip to content

Complete workshop 1 web scraping and PostgreSQL - #151

Open
darshanbaja wants to merge 1 commit into
UniCourt:mainfrom
darshanbaja:main
Open

Complete workshop 1 web scraping and PostgreSQL#151
darshanbaja wants to merge 1 commit into
UniCourt:mainfrom
darshanbaja:main

Conversation

@darshanbaja

Copy link
Copy Markdown

I completed the Workshop 1 homework by updating the Python web scraping script to scrape blog titles, URLs, authors, and publication dates from the Python Blog. I also added PostgreSQL support to store the scraped data and updated the Docker configuration to run the Python scraper and PostgreSQL together. Duplicate blog URLs are checked before inserting new records.

Copilot AI lite review requested due to automatic review settings August 28, 2026 03:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Workshop 1 scraper to collect structured post metadata from the Python Blog and persist results into a PostgreSQL database, with Docker configuration updates to run the scraper alongside Postgres.

Changes:

  • Replaced the sample scraping logic with a Python Blog scraper that extracts title, URL, author, and publish date.
  • Added PostgreSQL integration via psycopg2 with a duplicate-URL check before inserts.
  • Updated Docker/Docker Compose to install Python dependencies from requirements.txt and add a Postgres service.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
web_scraping_sample.py Scrapes Python Blog posts and writes results into PostgreSQL.
Dockerfile Switches dependency installation to use requirements.txt.
docker-compose.yaml Adds a Postgres service to run alongside the Python container.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread web_scraping_sample.py
Comment on lines +6 to +10
conn = psycopg2.connect(
host="psql-db",
database="workshop",
user="postgres",
password="postgres"
Comment thread web_scraping_sample.py
cursor = conn.cursor()

url = "https://blog.python.org/"
response = requests.get(url)
Comment thread web_scraping_sample.py
Comment on lines +36 to +50
cursor.execute(
"SELECT id FROM blogs WHERE url = %s",
(link,)
)

existing_blog = cursor.fetchone()

if existing_blog is None:
cursor.execute(
"""
INSERT INTO blogs (title, url, author, published_date)
VALUES (%s, %s, %s, %s)
""",
(title, link, author, date)
)
Comment thread Dockerfile
Comment on lines +5 to +7
COPY ./web_scraping_sample.py /root/workspace/src
COPY requirements.txt .

Comment thread docker-compose.yaml

psql-db:
image: postgres:14
container_name: workshop_postgres
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.

2 participants