Code debugging activity

Every week, a new cat or dog is the Ann Arbor’s 107one Pet-of-the-Week. The code below is supposed to get the pet of the week webpage, scrape the text of the title shown in the picture, and print it.

The pet of the week from August 22, 2020 is Chester.

However, it doesn’t work! Instead of printing the title text, it prints nothing.

Can you fix it? Here is the buggy code:

Plan 1: Get a soup from a URL
# Load libraries for web scraping
from bs4 import BeautifulSoup
import requests
# Get a soup from a URL
url = 'https://www.humanesociety.org/petsoftheweek/'
r = requests.get(url)
soup = BeautifulSoup(r.content, 'html.parser')
Plan 4: Get info from a single tag
# Get first tag of a certain type from the soup
tag = soup.find('a', class_='pt-cv-none cvplbd')
# Get info from tag
info = tag.get('href')
Plan 5: Print the info
# Print the info
print(info)

Try to fix the buggy code below. Run the code to save your progress.

You have attempted of activities on this page