Chocolate Scraping with Beautiful Soup (UnicodeEncodeError)

Exercise: LEARN WEB SCRAPING WITH BEAUTIFUL SOUP - Chocolate Scraping with Beautiful Soup

Link: https://www.codecademy.com/courses/learn-web-scraping/projects/chocolate-scraping-with-beautiful-soup

My problem: I’m getting…

“Traceback (most recent call last):
File “script.py”, line 12, in
print(soup)
UnicodeEncodeError: ‘ascii’ codec can’t encode character ‘\xa0’ in position 991: ordinal not in range(128)”

My code:

import codecademylib3_seaborn
from bs4 import BeautifulSoup
import requests
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

webpage = requests.get("https://s3.amazonaws.com/codecademy-content/courses/beautifulsoup/cacao/index.html")

soup = BeautifulSoup(webpage.content, "html.parser")

print(soup)

I copied this from another forumpost, but the author deleted it. But I still don’t know how to fix this. Can anyone please help?

Hi @benjamin_the_coder,

To resolve this problem, see the discussion Beautiful Soup Chocolate Project.

1 Like