Skip to content
Advertisement

UnicodeDecodeError when try to read data from ‘google.com’ in Python

I’m starting to learn about reading data from a website. But when I try to read data from google.com I encounter this error:

JavaScript

Below are my code (extractly as the instruction video, only different website):

JavaScript

What is wrong? Thanks in advance

Advertisement

Answer

Specifing the encoding and error handling should solve the problem:

JavaScript

When you are learning web scraping with python you might wanna have a look at BeautifulSoup: https://www.crummy.com/software/BeautifulSoup/bs4/doc/

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement