Skip to content

Instantly share code, notes, and snippets.

Last active May 31, 2020
What would you like to do?

This is a little python script to scrape the Dilbert of today and displays it. To install dependencies, use $ pip install requests BeautifulSoup4 Pillow

import requests
import urllib.request
import time
from bs4 import BeautifulSoup
import io
import datetime
import urllib
from PIL import Image
def DilbertURL(dateToFetch):
formatted_date = '{0}-{1}-{2}'.format(dateToFetch.year, dateToFetch.month,
todays_page = '{0}/'.format(formatted_date)
response = requests.get(todays_page)
dilbert_page_source = BeautifulSoup(response.text, 'html.parser')
link = dilbert_page_source.find("img", class_='img-comic')['src']
return "https:" + str(link)
response = requests.get(DilbertURL(
dilbert =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment