Skip to content

fix(web-search): accept div result titles in Brave keyless scraper#719

Closed
tongshu2023 wants to merge 1 commit into
THU-MAIC:mainfrom
tongshu2023:fix/brave-title-div-687
Closed

fix(web-search): accept div result titles in Brave keyless scraper#719
tongshu2023 wants to merge 1 commit into
THU-MAIC:mainfrom
tongshu2023:fix/brave-title-div-687

Conversation

@tongshu2023

Copy link
Copy Markdown
Contributor

Summary

Fixes #687. The keyless Brave web-search path returned 0 results because Brave moved the result title element:

  • old: <span class="search-snippet-title">Title</span>
  • now: <div class="title search-snippet-title line-clamp-1 ..." title="Title">Title</div>

The title regex matched <span> only, so if (!title) continue; skipped every snippet.

Changes

  • parseBraveSearchHtml accepts <span> or <div> for the title via a backreferenced (span|div) group, so the closing tag must match the opening one.
  • Test fixtures updated to Brave's current <div> markup; one legacy <span> case kept for back-compat (per the issue's suggestion).

Verification

  • Live check just now: https://search.brave.com/search?q=photosynthesis returns HTTP 200 with 20 data-type="web" snippets — 0 span titles, 20 div titles. The old parser extracts 0 of them; the fixed one extracts them all.
  • vitest run tests/web-search/brave.test.ts — 3/3 pass; prettier --check and eslint clean.

🤖 Generated with Claude Code

…HU-MAIC#687)

Brave moved the result title from a span with class search-snippet-title
to a div (class "title search-snippet-title line-clamp-1"), so the title
regex matched nothing and every snippet was skipped - the keyless path
returned 0 results on a 200 response with 20 snippets.

Accept either element via a backreferenced (span|div) group. Test fixtures
updated to the current div markup, with one legacy span case kept for
back-compat. Verified live: search.brave.com currently serves 20/20 div
titles and 0 span titles.

Fixes THU-MAIC#687

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tongshu2023

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate of #688, which predates this PR and fixes the same root cause (I missed it before opening — apologies for the noise). Leaving my live-verification data over there in support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Brave keyless scraper returns 0 results — result-title markup changed (span→div)

1 participant