---
name: 2taobaoquery
description: Run Goofish/Xianyu keyword searches with user-provided base browser cookies and a saved local session, without browser automation at query time. Use when the user wants to search keywords, batch query multiple keywords, export marketplace results, check whether a saved cookie still works, or bootstrap/refresh a session by providing base cookies from a working Goofish search page. The skill can dynamically obtain `_m_h5_tk` and related search cookies during bootstrap.
---

# 2taobaoquery

Use the bundled CLI to query the Goofish H5 search API from a saved cookie-backed session.

## Workflow

1. If the user already has a working saved session, run:

```bash
node /Users/not/.codex/skills/2taobaoquery/bin/2-taobao-query-skills.cjs query <keyword>
```

2. If the session is missing or the script returns `RGV587_ERROR::SM`, ask the user for the base cookie string from a working Goofish search page, then run:

```bash
node /Users/not/.codex/skills/2taobaoquery/bin/2-taobao-query-skills.cjs login --cookie '<document.cookie 或请求头 cookie>' --query <keyword>
```

3. If the user asks for multiple keywords, pass them as positional arguments:

```bash
node /Users/not/.codex/skills/2taobaoquery/bin/2-taobao-query-skills.cjs query --full 小红薯 business 酒店
```

4. If the user wants to save results to disk, use `--output`:

```bash
node /Users/not/.codex/skills/2taobaoquery/bin/2-taobao-query-skills.cjs export \
  --full --output results.json \
  小红薯 business 酒店
```

5. If the user wants to clear the saved session, run:

```bash
node /Users/not/.codex/skills/2taobaoquery/bin/2-taobao-query-skills.cjs logout
```

## Commands

- `login`: import cookie, bootstrap the search session, and verify it with one query
- `query`: run one or more keyword searches
- `export`: run queries and write JSON to disk
- `logout`: remove the local session file

## Cookie Requirements

Prefer the cookie string from a successful Goofish search page or from the successful search request headers.

The most useful base cookies for bootstrap are:

- `cookie2`
- `cna`
- `t`
- `_tb_token_`
- `tfstk`

The CLI dynamically obtains `_m_h5_tk`, `_m_h5_tk_enc`, and `mtop_partitioned_detect` during bootstrap. The user does not need to provide them manually.

## Output Modes

- Default mode: return response metadata and the first 5 items
- `--full`: return all items from the first page
- `--raw`: include raw API payload
- `--output <file>`: write the JSON result to disk

## Session Handling

- Saved session file: `/Users/not/.codex/skills/2taobaoquery/session.json`
- The CLI automatically refreshes the saved session after a successful request
- Do not clear the session unless the user explicitly wants to replace it or debugging requires a clean bootstrap

## Notes

- This skill targets Goofish/Xianyu search, not generic Taobao PC search
- Query-time browser automation is not required once a valid cookie-backed session has been imported
- If the user asks whether the cookie still works, run a simple keyword like `codex` and report `ok/status/itemCount`
