Skip to content

fix(scraper): repair scraping broken in 0.1.5 (#31) - #32

Merged
marcinobel merged 1 commit into
developfrom
feature/issue-31-fix-broken-scrape
Nov 17, 2026
Merged

marcinobel merged 1 commit into
developfrom
feature/issue-31-fix-broken-scrape

Conversation

@marcinobel

Copy link
Copy Markdown
Member

Summary

revcli 0.1.5 cannot complete a normal scrape: it crashes after the first ~10 reviews, leaves long reviews cut off, and reports a dead Google session as signed in. This PR fixes findings 1–7 of #31 and adds browser tests that run the in-page code, so this class of regression fails CI.

Refs #31 – the issue stays open until 0.1.6 is published through the release workflow.

Changes

Fixed

  • Scroll crash (finding 1): scrollDown() passes the scroll step into the page instead of reading a Node-side constant inside page.evaluate.
  • Cut-off reviews (finding 2): the expand step marks each "More" button and clicks it by that mark, then confirms the result. Google now removes the button on click, which made the positional loop skip every second review. A warning names how many collected reviews stay cut off.
  • Session state (findings 3–4): getSessionState() is the single check for "Google accepts this session" (cookies plus language-independent account / sign-in links). auth status reports an expired session as not signed in (exit 1); auth waits for a fresh sign-in and closes on its own.
  • Limited view (finding 5): raised as a typed AUTH_REQUIRED error – never retried, one message that says to run revcli auth, for every sort order. Headed mode asks for sign-in and continues.
  • Non-place links (finding 6): fail once with NOT_A_PLACE. The dead README batch example link is replaced.
  • Short links: maps.app.goo.gl links now redirect in page script, so hl=en was lost and signed-out or non-English profiles got a localized page. The navigator waits for the destination before forcing English. Found during live verification.
  • Errors: one top-level handler; no stack trace without --verbose; Playwright call logs are removed from messages, including batch failure lines.

Added

  • src/core/fatal.ts, tests/browser/ (scroll, expand, session, navigation against local fixtures, all network blocked), tests/browser-import-guard.test.ts, tests/auth-command.test.ts, tests/fatal.test.ts, tests/selectors.test.ts.
  • npm run test:browser; CI step that installs the Chromium headless shell. release.yml is not touched.

Docs

  • README.md, AGENTS.md, docs/selector-maintenance.md (current limited view, session markers, expand lesson, "Last verified: 2026-11-17"), CHANGELOG.md ([Unreleased]). No version bump.

Testing

Automated

  • npm run typecheck – pass
  • npm test – 419 tests in 25 files pass (297 in 17 before)
  • npm run build, npm run check:pack, npm run test:package – pass
  • Self-check: with the scroll fix reverted, the scroll tests fail with ReferenceError: SCROLL_STEP is not defined; with the old positional expand loop restored, 9 of 10 expand tests fail
  • Lint: the project has no lint command

Live, against Google Maps on 2026-11-17 (hl=en, EEA)

  • 300 of 300 unique reviews, exit 0 – source headless, source headed, built headless, built headed
  • No long review left cut off (300-, 799- and 1,671-review scrapes)
  • auth status: dead session → "expired", exit 1; signed-out → exit 1; valid session → exit 0
  • Dead session, scrape --headless, all four sort orders: exit 1, one message, 0 retries, 0 stack-trace lines
  • Non-place short link: exit 1, one message
  • Input formats: long URL, short URL, ftid, CID, ChIJ; sort orders relevant / highest / lowest; CSV; validate; batch (invalid line skipped); --resume
  • Owner-chosen links: 799 of 799 and 1,671 of 1,671 reviews, exit 0
  • Not run live: revcli auth closing on its own after a real sign-in on a dead session (finding 4), and the headed scrape "ask for sign-in, then continue" path (finding 5). Both need a manual Google sign-in. Covered by automated tests only.

Notes

Quality gates

  • Secret scan on the change set: no hits.
  • npm audit fails, unchanged by this PR: 10 high, 2 critical. All but one are in dev tooling (vitest, tsup and their dependencies); one high is in zod. This PR changes no dependency. Owner decision: handle the upgrades separately.

Accepted tech debt (follow-ups)

  • Headless batch with a dead session fails every location separately instead of stopping at the first one.
  • The limited-view banner is matched inside one text node; a banner split across tags would be missed for --sort relevant (the Sort sign-in dialog covers the other three sort orders).
  • If the account-link selector goes stale, auth status falls back to trusting the cookies ("unconfirmed"), and the sign-in wait ends in its 5-minute timeout.
  • extractor.ts and scraper/auth.ts each hold several responsibilities; a split is deferred.
  • Terminal control characters in echoed input and business names are not filtered (older code).
  • In-page code is tested through vitest's transform only; tsx and the built package are covered by live runs.
  • .github/workflows/release.yml:282 has ${{ github.repository }} inside a run: block, against the repo's own invariant. Not touched here.

Observed, outside this issue

  • On a 1,671-review place, 34 of 673 translated reviews have no original-language text (the translation is correct and the log warns). The misses are in the deepest part of the list; the cause is not verified.
  • Some complete, short reviews end with " …" in Google's own rendering.

After merge

  • Release 0.1.6 through the two-step Release workflow (bump PR, then publish).

https://claude.ai/code/session_01PuLVjZfdZVDn9e5QnCEtCH

Scrapes crashed after the first ~10 reviews, long reviews stayed cut
off, and a dead Google session was reported as signed in.

- scroll: pass the scroll step into the page instead of reading a
  Node-side constant inside page.evaluate (ReferenceError on the
  second scroll)
- expand: click each "More" button by a mark on the element and
  confirm the result; Google now removes the button on click, which
  made the positional loop skip every second review. Warn with the
  number of reviews that stay cut off
- session: one check for "Google accepts this session"
  (getSessionState) used by auth, auth status and the sign-in wait;
  an expired session is no longer reported as signed in
- limited view: typed AUTH_REQUIRED error, never retried, one message
  that says to run `revcli auth`, for every sort order; headed mode
  asks for sign-in and continues
- non-place links fail once with NOT_A_PLACE
- short links: wait for the in-page redirect before forcing hl=en, so
  signed-out and non-English profiles get an English page
- errors: one top-level handler, no stack trace without --verbose,
  Playwright call logs removed from messages
- tests: browser tests run the scroll, expand, session and navigation
  code in headless Chromium against local fixtures; CI installs
  Chromium
- docs: README, AGENTS.md, selector maintenance guide, CHANGELOG

Refs #31

Claude-Session: https://claude.ai/code/session_01PuLVjZfdZVDn9e5QnCEtCH
@marcinobel
marcinobel merged commit 1ee8a40 into develop Nov 17, 2026
1 check passed
@marcinobel
marcinobel deleted the feature/issue-31-fix-broken-scrape branch November 17, 2026 20:09
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.

1 participant