Scraping Smiles: When Quotes and Jokes Collide

Day 16 of 100 Days Coding Challenge: Python

Back in the day, I used to hunt for quotes like a digital philosopher—scrolling through pages of wisdom, looking for that one line to slap on a journal page or a sticky note. Some days were tough, and nothing hits quite like a well-timed dad joke to lift the spirits. At one point, I even had one of those “joke-a-day” calendars perched on my desk like a tiny comedian in paper form. So today, I figured, why not build my own quote-and-joke fetching machine? Just a little web scraping magic to keep inspiration (and groans) flowing.

Today’s Motivation / Challenge

Today’s project is all about turning the internet into your personal mood board—one quote and one groan-worthy joke at a time. The goal? Learn the basics of web scraping without frying your brain. You’ll send a polite request to a webpage, receive a heap of HTML in return, and pick out the good stuff—like a claw machine that actually works. It’s a small but mighty step into real-world automation.

Purpose of the Code (Object)

This script scrapes quotes from a publicly available website and fetches a dad joke from an API. It prints both to your terminal for an instant dose of motivation and humor. There’s no fancy GUI or app—just simple code that works behind the scenes like a cheerful assistant with a dry sense of humor.

AI Prompt: Make it cleaner

Create a Python script that scrapes quotes from http://quotes.toscrape.com and fetches a random dad joke from https://icanhazdadjoke.com. Display both in the terminal using clean formatting.

Functions & Features

  • Scrapes inspirational quotes and author names from a static website
  • Pulls a random dad joke from an online API
  • Prints both quote and joke to the terminal in a readable format

Requirements / Setup

pip install requests

pip install beautifulsoup4

Python 3.6+ recommended.

Minimal Code Sample

import requests

from bs4 import BeautifulSoup

# Get quote

soup = BeautifulSoup(requests.get(“http://quotes.toscrape.com”).text, “html.parser”)

quote = soup.find(“span”, class_=”text”).get_text()

author = soup.find(“small”, class_=”author”).get_text()

# Get dad joke

joke = requests.get(“https://icanhazdadjoke.com/”, headers={“Accept”: “text/plain”}).text.strip()

print(f”{quote} — {author}”)

print(f”Joke of the Day: {joke}”)

This snippet shows the basic scraping and fetching process in just a few lines.

Dad Joke Fetcher

Notes / Lessons Learned

The program itself was refreshingly simple—point, click, extract. However, once the quote and joke came flying out of the terminal like a stand-up act with no stage, I realized something: terminal text isn’t exactly audience-friendly. It’s like watching Shakespeare on a Post-it note. Formatting matters. Also, working with APIs felt smoother than HTML scraping—less messy, like ordering takeout instead of cooking with whatever’s left in the fridge.

Optional Ideas for Expansion

  • Save daily quotes and jokes to a .txt or .csv file to build your own “Laughspiration” archive
  • Schedule the script to run automatically each morning (with cron or Task Scheduler)
  • Add categories for quotes (e.g., motivational, funny, philosophical) and let users choose