Skip to content

Add Homework 1Add homework 1 - #153

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

Add Homework 1Add homework 1#153
pratham7187 wants to merge 1 commit into
UniCourt:mainfrom
pratham7187:main

Conversation

@pratham7187

Copy link
Copy Markdown

No description provided.

Copilot AI lite review requested due to automatic review settings August 28, 2026 04:05

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

This PR adds a simple web-scraping pipeline that fetches posts from the Python blog and stores results in a PostgreSQL database, packaged to run via Docker Compose for the workshop.

Changes:

  • Added a scraper.py script that scrapes blog posts and inserts them into Postgres (creating the table if needed).
  • Added Docker and Compose configuration to run Postgres + the scraper together.
  • Updated Python dependencies and added a small DB connectivity test script.

Reviewed changes

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

Show a summary per file
File Description
scraper.py Implements scraping + DB writes; introduces DB connection/config and insert behavior.
test_db.py Adds a quick Postgres connection smoke test script.
requirements.txt Switches dependency specification format (pinned → unpinned).
Dockerfile Builds a container image to run the scraper.
docker-compose.yml Defines the Postgres service and runs the scraper after DB healthcheck.

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

Comment thread scraper.py
Comment on lines +1 to +11
import requests
from bs4 import BeautifulSoup
import psycopg2

conn = psycopg2.connect(
host="db",
database="blogdb",
user="postgres",
password="password",
port=5432
)
Comment thread scraper.py
Comment on lines +26 to +27
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
Comment thread scraper.py
Comment on lines +33 to +35
for post in posts:
title = post.get_text(" ", strip=True)

Comment thread test_db.py
Comment on lines +1 to +9
import psycopg2

conn = psycopg2.connect(
host="localhost",
database="blogdb",
user="postgres",
password="password",
port=5432
)
Comment thread scraper.py
Comment on lines +17 to +22
cursor.execute("""
CREATE TABLE IF NOT EXISTS blogs (
id SERIAL PRIMARY KEY,
title TEXT NOT NULL
)
""")
Comment thread scraper.py
Comment on lines +36 to +39
cursor.execute(
"INSERT INTO blogs (title) VALUES (%s)",
(title,)
)
Comment thread docker-compose.yml
Comment on lines +4 to +12
environment:
POSTGRES_DB: blogdb
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d blogdb"]
interval: 5s
timeout: 5s
retries: 10
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