Skip to content

feat(dianping): browser adapter — search + shop on www.dianping.com#1309

Merged
jackwener merged 3 commits intomainfrom
feat/dianping-search-shop
May 4, 2026
Merged

feat(dianping): browser adapter — search + shop on www.dianping.com#1309
jackwener merged 3 commits intomainfrom
feat/dianping-search-shop

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

Adds two new browser-mode adapters for 大众点评 (dianping) on www.dianping.com:

  • dianping search "<keyword>" --city <name|id> --limit <n> — keyword shop/restaurant search.
    Columns: rank, shop_id, name, rating, reviews, price, cuisine, district, url.
  • dianping shop <shop_id> (alias detail) — shop detail field/value sheet
    (name, rating, breakdown 口味/环境/服务/食材, reviews, price, rank, hours, address,
    subway, features, url).

search.shop_id round-trips into shop, so listing→detail pairing is satisfied.

Why www.dianping.com (PC site)

m.dianping.com is intentionally crippled for non-mobile UAs — body renders as 2 chars
to push users into the native app. The PC site renders search results SSR and does not
require JS hydration, so adapters target it directly with Strategy.COOKIE.

Auth handling

utils.detectAuthOrEmpty({text, url}, hint) inspects both response text and the
final URL for:

  • Meituan Yoda captcha redirect → verify.meituan.comAuthRequiredError
    (message embeds the captcha URL so the user can click and clear it in the same profile)
  • Login redirect → login.dianping.com / account.dianping.comAuthRequiredError
  • Otherwise → EmptyResultError

Verified live with opencli dianping search 火锅 --city beijing --trace on:
the request hit the Yoda captcha and the adapter raised
AUTH_REQUIRED: dianping search "火锅" blocked by captcha — open https://verify.meituan.com/...
with the actual requestCode. Trace artifact at
~/.opencli/profiles/default/traces/20260504142805-4accf89f/.

Live happy-path verification requires clearing the captcha first in the
site:dianping browser profile. Once cleared, opencli browser verify dianping/search
can be run with --write-fixture to seed the verify fixture.

Listing↔detail ID pairing

Adds 'shop' to DETAIL_NAMES in scripts/check-listing-id-pairing.mjs so the
convention gate now covers this site. After the change:
Scanned 35 site(s) / 78 listings ✓ — every listing carries an id-shaped column.

Files

  • clis/dianping/utils.js — CITY_ID map (20 cities), resolveCityId,
    detectAuthOrEmpty({text, url}, hint), parseReviewCount, parsePrice
  • clis/dianping/search.js — keyword search, parses #shop-all-list li SSR DOM
  • clis/dianping/shop.js — detail sheet, parses .shop-head + breakdown + features
  • docs/adapters/browser/dianping.md — adapter docs (commands, examples, troubleshooting)
  • docs/.vitepress/config.mts + docs/adapters/index.md — sidebar/index entries
  • scripts/check-listing-id-pairing.mjs'shop' added to DETAIL_NAMES
  • cli-manifest.json — rebuilt (662 → 664 entries)

Test plan

  • pnpm build-manifest — 664 entries
  • pnpm typecheck — clean
  • node scripts/check-listing-id-pairing.mjs --strict — 35/78 ✓
  • pnpm docs:build — clean
  • Live captcha-path verified (AuthRequiredError + captcha URL in trace)
  • Live happy-path verify (requires manual captcha clearance, blocking on profile auth)

@jackwener jackwener force-pushed the feat/dianping-search-shop branch from 82009c4 to 09a98ad Compare May 4, 2026 14:46
jackwener added 3 commits May 4, 2026 22:56
Adds two browser-mode adapters for the dianping (大众点评) PC site:

- `dianping search "<keyword>" --city <name|id> --limit <n>`: keyword
  shop/restaurant search. Returns rank, shop_id, name, rating, reviews,
  price, cuisine, district, url. shop_id round-trips into `dianping shop`.
- `dianping shop <shop_id>` (alias `detail`): shop detail sheet
  (field/value rows: name, rating, breakdown 口味/环境/服务/食材, reviews,
  price, rank, hours, address, subway, features, url).

Both use Strategy.COOKIE on www.dianping.com (the PC site renders search
SSR and does not require JS hydration). m.dianping.com is intentionally
crippled for non-mobile UAs, so it's not used.

Auth detection (utils.detectAuthOrEmpty) inspects both response text and
final URL for the Meituan Yoda captcha redirect (verify.meituan.com) and
the dianping login redirect; raises AuthRequiredError with the captcha
URL embedded so the user can clear it manually in the same profile.

Listing↔detail id pairing: search.shop_id → shop.<id>. Adds 'shop' to
DETAIL_NAMES in scripts/check-listing-id-pairing.mjs so the convention
gate scans this site (35 sites / 78 listings now covered).
@jackwener jackwener force-pushed the feat/dianping-search-shop branch from 83d03ef to 2ff6b3e Compare May 4, 2026 14:57
@jackwener jackwener merged commit 0f806e9 into main May 4, 2026
11 checks passed
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