This is the code I currently have
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36'}
r = requests.get("http://www.google.com", headers=headers)
page_text = r.text
soup = BeautifulSoup(page_text, 'html.parser')
print(soup.prettify())
In theory it should send a request to google, get the text back and use beautifulsoup's method of prettify()
Here's their example code (from http://www.crummy.com/software/BeautifulSoup/bs4/doc/#getting-help)
from bs4 import BeautifulSoup
soup = BeautifulSoup(html_doc, 'html.parser')
print(soup.prettify())
Everytime I run this code I get the codec error. Here's a screenshot of the exact error
FOUND A SOLUTION
The solution is instead of using print() to use this print method from a stack exchange member.
def uprint(*objects, sep=' ', end='\n', file=sys.stdout):
enc = file.encoding
if enc == 'UTF-8':
print(*objects, sep=sep, end=end, file=file)
else:
f = lambda obj: str(obj).encode(enc, errors='backslashreplace').decode(enc)
print(*map(f, objects), sep=sep, end=end, file=file)