Olá Estou tentando extrair dados do site OLX e continua aparecendo o erro HTTPError: HTTP Error 403: Forbidden mesmo após informar o user-agent. Existe alguma forma de extrair os dados do OLX?
from urllib.request import Request, urlopen
from urllib.error import URLError, HTTPError
url = 'https://www.webmotors.com.br/carros/sc-florianopolis'
headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 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)