[Python] Como fazer scraping no Reclame aqui

Discussão em 'Python' iniciado por Stack, Julho 4, 2025.

  1. Stack

    Stack Membro Participativo

    Estou iniciando um projeto para fins de estudo. Gostaria de um script que precisaria consumir dados do site (Reclame Aqui) de empresas específicas. Tentei contatá-los para ver se poderiam fornecer uma API, mas não conseguiram. Tentei fazer scraping, mas mesmo tentando reduzir o número de chamadas, o resultado foi "muitas requisições". Alguém sabe como posso fazer isso?

    ------- edit ps: estou usando um notebook no anaconda Reclamações: "https://www.reclameaqui.com.br/empresa/santander/lista-reclamacoes/"

    Gostaria de pesquisar reclamações na lista de reclamações e salvá-las em um dataframe


    from selenium import webdriver
    from selenium.webdriver.chrome.service import Service
    from webdriver_manager.chrome import ChromeDriverManager
    from selenium.webdriver.common.by import By
    import pandas as pd
    import time

    # Iniciar navegador (visível)
    driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))

    # Acessar a página
    url = "https://www.reclameaqui.com.br/empresa/santander/lista-reclamacoes/"
    driver.get(url)
    time.sleep(10) # Espera o carregamento completo

    # Seleciona os cards de reclamações
    cards = driver.find_elements(By.CSS_SELECTOR, "div.rai-card")

    # Coletar as 5 primeiras
    reclamacoes = []
    for card in cards[:5]:
    try:
    titulo = card.find_element(By.CSS_SELECTOR, "h4").text
    data = card.find_element(By.CSS_SELECTOR, "span.rai-card-subtitle").text
    resumo = card.find_element(By.CSS_SELECTOR, "p").text
    status = card.find_element(By.CSS_SELECTOR, "div.rai-status-label").text

    reclamacoes.append({
    "Título": titulo,
    "Data": data,
    "Resumo": resumo,
    "Status": status
    })
    except Exception as e:
    print("Erro ao extrair uma reclamação:", e)

    # Encerrar navegador
    driver.quit()

    # Salvar em CSV
    df = pd.DataFrame(reclamacoes)
    df.to_csv("reclamacoes_santander.csv", index=False, encoding="utf-8")

    print("✅ Arquivo CSV criado com sucesso: reclamacoes_santander.csv")

    in this part:

    Pegar os blocos



    cards = driver.find_elements(By.CSS_SELECTOR, "div.rai-card") # seletor genérico mais seguro

    ERRO:



    ConnectionRefusedError Traceback (most recent call last)
    ~\anaconda3\lib\site-packages\urllib3\connection.py in _new_conn(self)
    168 try:
    --> 169 conn = connection.create_connection(
    170 (self._dns_host, self.port), self.timeout, **extra_kw

    ~\anaconda3\lib\site-packages\urllib3\util\connection.py in create_connection(address, timeout, source_address, socket_options)
    95 if err is not None:
    ---> 96 raise err
    97

    ~\anaconda3\lib\site-packages\urllib3\util\connection.py in create_connection(address, timeout, source_address, socket_options)
    85 sock.bind(source_address)
    ---> 86 sock.connect(sa)
    87 return sock

    ConnectionRefusedError: [WinError 10061] Nenhuma conexão pôde ser feita porque a máquina de destino as recusou ativamente

    During handling of the above exception, another exception occurred:

    NewConnectionError Traceback (most recent call last)
    ~\anaconda3\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    698 # Make the request on the httplib connection object.
    --> 699 httplib_response = self._make_request(
    700 conn,

    ~\anaconda3\lib\site-packages\urllib3\connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    393 else:
    --> 394 conn.request(method, url, **httplib_request_kw)
    395

    ~\anaconda3\lib\site-packages\urllib3\connection.py in request(self, method, url, body, headers)
    233 headers["User-Agent"] = _get_default_user_agent()
    --> 234 super(HTTPConnection, self).request(method, url, body=body, headers=headers)
    235

    ~\anaconda3\lib\http\client.py in request(self, method, url, body, headers, encode_chunked)
    1254 """Send a complete request to the server."""
    -> 1255 self._send_request(method, url, body, headers, encode_chunked)
    1256

    ~\anaconda3\lib\http\client.py in _send_request(self, method, url, body, headers, encode_chunked)
    1300 body = _encode(body, 'body')
    -> 1301 self.endheaders(body, encode_chunked=encode_chunked)
    1302

    ~\anaconda3\lib\http\client.py in endheaders(self, message_body, encode_chunked)
    1249 raise CannotSendHeader()
    -> 1250 self._send_output(message_body, encode_chunked=encode_chunked)
    1251

    ~\anaconda3\lib\http\client.py in _send_output(self, message_body, encode_chunked)
    1009 del self._buffer[:]
    -> 1010 self.send(msg)
    1011

    ~\anaconda3\lib\http\client.py in send(self, data)
    949 if self.auto_open:
    --> 950 self.connect()
    951 else:

    ~\anaconda3\lib\site-packages\urllib3\connection.py in connect(self)
    199 def connect(self):
    --> 200 conn = self._new_conn()
    201 self._prepare_conn(conn)

    ~\anaconda3\lib\site-packages\urllib3\connection.py in _new_conn(self)
    180 except SocketError as e:
    --> 181 raise NewConnectionError(
    182 self, "Failed to establish a new connection: %s" % e

    NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000001ECD88CFB50>: Failed to establish a new connection: [WinError 10061] Nenhuma conexão pôde ser feita porque a máquina de destino as recusou ativamente

    During handling of the above exception, another exception occurred:

    MaxRetryError Traceback (most recent call last)
    <ipython-input-15-9066030c2018> in <module>
    1 # Pegar os blocos
    ----> 2 cards = driver.find_elements(By.CSS_SELECTOR, "div.rai-card") # seletor genérico mais seguro

    ~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in find_elements(self, by, value)
    790 # Return empty list if driver returns null
    791 # See https://github.com/SeleniumHQ/selenium/issues/4555
    --> 792 return self.execute(Command.FIND_ELEMENTS, {"using": by, "value": value})["value"] or []
    793
    794 @property

    ~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params)
    380 params["sessionId"] = self.session_id
    381
    --> 382 response = self.command_executor.execute(driver_command, params)
    383 if response:
    384 self.error_handler.check_response(response)

    ~\anaconda3\lib\site-packages\selenium\webdriver\remote\remote_connection.py in execute(self, command, params)
    402 trimmed = self._trim_large_entries(params)
    403 LOGGER.debug("%s %s %s", command_info[0], url, str(trimmed))
    --> 404 return self._request(command_info[0], url, body=data)
    405
    406 def _request(self, method, url, body=None):

    ~\anaconda3\lib\site-packages\selenium\webdriver\remote\remote_connection.py in _request(self, method, url, body)
    426
    427 if self._client_config.keep_alive:
    --> 428 response = self._conn.request(method, url, body=body, headers=headers, timeout=self._client_config.timeout)
    429 statuscode = response.status
    430 else:

    ~\anaconda3\lib\site-packages\urllib3\request.py in request(self, method, url, fields, headers, **urlopen_kw)
    76 )
    77 else:
    ---> 78 return self.request_encode_body(
    79 method, url, fields=fields, headers=headers, **urlopen_kw
    80 )

    ~\anaconda3\lib\site-packages\urllib3\request.py in request_encode_body(self, method, url, fields, headers, encode_multipart, multipart_boundary, **urlopen_kw)
    168 extra_kw.update(urlopen_kw)
    169
    --> 170 return self.urlopen(method, url, **extra_kw)

    ~\anaconda3\lib\site-packages\urllib3\poolmanager.py in urlopen(self, method, url, redirect, **kw)
    373 response = conn.urlopen(method, url, **kw)
    374 else:
    --> 375 response = conn.urlopen(method, u.request_uri, **kw)
    376
    377 redirect_location = redirect and response.get_redirect_location()

    ~\anaconda3\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    781 "Retrying (%r) after connection broken by '%r': %s", retries, err, url
    782 )
    --> 783 return self.urlopen(
    784 method,
    785 url,

    ~\anaconda3\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    781 "Retrying (%r) after connection broken by '%r': %s", retries, err, url
    782 )
    --> 783 return self.urlopen(
    784 method,
    785 url,

    ~\anaconda3\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    781 "Retrying (%r) after connection broken by '%r': %s", retries, err, url
    782 )
    --> 783 return self.urlopen(
    784 method,
    785 url,

    ~\anaconda3\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    753 e = ProtocolError("Connection aborted.", e)
    754
    --> 755 retries = retries.increment(
    756 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
    757 )

    ~\anaconda3\lib\site-packages\urllib3\util\retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    572
    573 if new_retry.is_exhausted():
    --> 574 raise MaxRetryError(_pool, url, error or ResponseError(cause))
    575
    576 log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)

    MaxRetryError: HTTPConnectionPool(host='localhost', port=16453): Max retries exceeded with url: /session/c82213a39cb17d63a2f4a28a808732fb/elements (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001ECD88CFB50>: Failed to establish a new connection: [WinError 10061] Nenhuma conexão pôde ser feita porque a máquina de destino as recusou ativamente'))

    Continue reading...

Compartilhe esta Página