#Seguindo os passos da aula e tentando requisitar a pagina da OLX deu erro
Codigo:
from urllib.request import urlopen from bs4 import BeautifulSoup
url = 'https://pr.olx.com.br/regiao-de-curitiba-e-paranagua/videogames'
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36'}
try: req = Request(url, headers = headers) response = urlopen(req) print(response.read())
except HTTPError as e: print(e.status, e.reason)
except URLError as e: print(e.reason)
Erro:
NameError Traceback (most recent call last) in 8 try: ----> 9 req = Request(url, headers = headers) 10 response = urlopen(req)
NameError: name 'Request' is not defined
During handling of the above exception, another exception occurred:
NameError Traceback (most recent call last) in 11 print(response.read()) 12 ---> 13 except HTTPError as e: 14 print(e.status, e.reason) 15
NameError: name 'HTTPError' is not defined