Black Friday: 50% off the Starter plan with the code BLACKFRIDAY50 — See the offer
Brave
|
por Autom Team

search.brave.com/go/v1: ler Location

Os resultados web do Brave Search passam por /go/v1. Não decodifique o token. Peça o URL com a SERP como Referer e leia Location.

O Brave Search já não põe o destino no href orgânico. Os resultados web apontam para /go/v1/<token> em https://search.brave.com. O token não é um URL codificado. Não o decodifique.

O Brave tem de enviar o leitor para algum lado. Põe esse URL no cabeçalho HTTP Location, e só quando o Referer é a SERP de onde veio o link.

A mesma ideia de google.com/goto, com uma regra a mais. Referer: https://search.brave.com/ ou um /search nu devolve a página de camuflagem (200) e nenhum Location.

Exemplos em curl, Python, Node e Go: github.com/automdev/brave-gov1-url-fix. A API Brave Search da Autom faz esse salto no servidor.

Uma frase

Não siga o redirecionamento. Envie a SERP como Referer. Leia Location.

GET /go/v1/<token> HTTP/1.1
Host: search.brave.com
Referer: https://search.brave.com/search?q=piloterr+api&source=web

HTTP/1.1 302 Found
Location: https://www.piloterr.com/library

HEAD e GET funcionam. Não siga.

Imagens e vídeos continuam com links https diretos. A mudança é a SERP web.

curl

curl -sI --max-redirs 0 \
  -H 'Referer: https://search.brave.com/search?q=piloterr+api&source=web' \
  'https://search.brave.com/go/v1/TOKEN' \
  | grep -i '^location:'

-I é HEAD. Sem -L, o curl não segue. A linha Location: é o URL real.

Python

import requests

url = "https://search.brave.com/go/v1/TOKEN"
serp = "https://search.brave.com/search?q=piloterr+api&source=web"
r = requests.head(url, allow_redirects=False, headers={"Referer": serp}, timeout=10)
print(r.status_code, r.headers.get("Location"))

Se o HEAD não trouxer Location, tente de novo com GET sem seguir.

Na Autom

A API Brave Search já resolve /go/v1 e devolve o URL final em organic_results[].link.

curl -s https://api.autom.dev/v1/brave/search \
  -H "x-api-key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"piloterr api","gl":"us","hl":"en"}'

Código e README: github.com/automdev/brave-gov1-url-fix.

Leitura relacionada

1.000 pedidos grátis em preços Autom, chave de API em app.autom.dev/register.

SERP API

Discover why Autom is the preferred API provider for developers.