360 Secure SkillHub
360 安全技能中心

amazon-shopper

输入关键词后,尝试多种措辞检索 Amazon 商品并解析标题、页面与图片中的规格、浓度,按每公斤有效成分、每 GB 或每公斤价格排序;逐个读取商品页确认库存,未核实的商品单列;可选 Apify 抓取和命令行 LLM 辅助解析。

分类:生活
globalcaos
globalcaos
热度 52.34
最近更新 2026-12-03 00:40:18

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add globalcaos/tinker-amazon-shopper
兼容性
通用兼容
联网要求
需要联网
数据出网
必须出网
Metadata
name
amazon-shopper
version
1.2.4
description
Amazon shopping that ends in a decision, not a page of links. It tries several phrasings of your query, reads the size and strength out of each listing, and ranks on the number that decides the buy: €/kg of active ingredient, €/GB, €/kg. Only products whose page says they can be bought are ranked; the ones it could not check are listed apart as unknown. A strength counts only when the listing states it or you confirm it. It reads the public pages of amazon.es with no account and no cookies, and has no code that buys, logs in or changes anything. To understand a listing it sends product titles, page text and sometimes the product photo to a command-line LLM client that runs with no tools (claude by default, AMAZON_SHOPPER_LLM_CMD picks another or none) and uses the account that client is signed in to. Optional and off until you set it up: Apify, a paid scraper that receives your search terms, with your own token or through a local Secret Keeper proxy. Use when the user asks "find me X on Amazon and tell me the best deal" or "best price per kg/GB of X". Not for live price tracking or anything that needs your account. It copies the delivery text a search page shows to a visitor with no account, which is not a promise for your address. Built for the TinkerClaw fork: github.com/globalcaos/tinkerclaw.
metadata
{"openclaw":{"emoji":"🛒","notes":{"security":"Read-only. It requests pages from amazon.es over HTTPS and product photos from Amazon's image servers; every host is on a fixed list and must resolve to a public address, and the address that was checked is the one it connects to. No account, no cookies, no browser, no basket or order code. One other program can run, from a fixed list and only from folders that no other user can write to: an LLM client. It receives product titles, page text and product photos and passes them to its own provider, on your account there; AMAZON_SHOPPER_LLM_CMD=none turns it off. It is started with no tools, so it cannot read files, run commands or open pages, and listing text reaches it as a JSON value apart from the instructions. Apify is off until AMAZON_SHOPPER_APIFY_TOKEN is set, or until a local Secret Keeper proxy is configured for it (KEEPER_SERVICES with apify, KEEPER_PROXY and a client token); then your search terms and the product ids go to api.apify.com and each run costs credit. Both say so on stderr at the first call. One temporary SQLite file per task, marked as this tool's and deleted by close."},"env":[{"name":"AMAZON_SHOPPER_LLM_CMD","sensitive":false,"required":false,"description":"Which LLM client reads the listings: claude (the default), claude --model <name>, llm -m <name> or ollama run <name>. none = no LLM; titles are then read by rules only. A path, any other program and any other argument are refused."},{"name":"AMAZON_SHOPPER_APIFY_TOKEN","sensitive":true,"required":false,"description":"Your Apify token. Unset: Apify is not used, unless the Secret Keeper variables below are set. Sent only to api.apify.com, in the Authorization header."},{"name":"KEEPER_SERVICES","sensitive":false,"required":false,"description":"For people who run TinkerClaw's Secret Keeper, a local credential proxy. With apify in this comma-separated list, plus KEEPER_PROXY and a client token, Apify is ON without AMAZON_SHOPPER_APIFY_TOKEN: the proxy adds the token."},{"name":"KEEPER_PROXY","sensitive":false,"required":false,"description":"Address of that proxy. Must be plain http on 127.0.0.1, localhost or [::1]; anything else is refused."},{"name":"KEEPER_CLIENT_TOKEN","sensitive":true,"required":false,"description":"Client token for that proxy. Sent only to the address above."},{"name":"KEEPER_TOKEN_SHOPPER","sensitive":true,"required":false,"description":"This program's own client token for that proxy, used before KEEPER_CLIENT_TOKEN."},{"name":"AMAZON_SHOPPER_TMPDIR","sensitive":false,"required":false,"description":"Folder for the temporary task file. Default: the system temp folder."},{"name":"PATH","sensitive":false,"required":false,"description":"Where the LLM client is looked up. A copy is used only if it and every folder leading to it belong to root or you and nobody else can write there."},{"name":"SDCARD_MIN_GB","sensitive":false,"required":false,"description":"Smallest memory card shown in the chart. Default 128."},{"name":"AMAZON_SHOPPER_TEST_FIXTURES","sensitive":false,"required":false,"description":"Tests only. JSON file with canned pages; read as data."},{"name":"MOCK_LLM_RESPONSE_FILE","sensitive":false,"required":false,"description":"Tests only. JSON file with canned LLM answers."}],"requires":{"bins":["node"],"bins_optional":["claude","llm","ollama"]},"permissions":{"network":{"required":true,"scope":"HTTPS to www.amazon.es (search and product pages) and to Amazon's image servers (product photos). Optional: api.apify.com, or your own loopback proxy in its place. The LLM client makes its own connection to its provider."},"shell":{"required":true,"scope":"An LLM client, unless AMAZON_SHOPPER_LLM_CMD=none. Started directly with an argument list, never through a shell, and with no tools."},"env_read":{"required":true,"scope":"Only the variables listed above."},"file_read":{"required":true,"scope":"Its own task file and the dataset file you name."},"file_write":{"required":true,"scope":"One SQLite file per task in the temp folder, and the output file you name. scripts/dev-capture-fixtures.mjs, which you run by hand to refresh the saved test pages, writes into tests/fixtures."},"file_delete":{"required":true,"scope":"close removes that task's SQLite file and its two journals, and only when the file carries this tool's mark and holds that task. Nothing else is deleted."},"credentials":{"required":false,"scope":"None by default. Optional: AMAZON_SHOPPER_APIFY_TOKEN, or KEEPER_CLIENT_TOKEN / KEEPER_TOKEN_SHOPPER for the local proxy. Read from the environment, never stored or printed. The LLM client uses its own sign-in, which this skill does not read."}}}}
repository
https://github.com/globalcaos/tinkerclaw
homepage
https://github.com/globalcaos/tinkerclaw

Amazon Shopper

One of dozens of skills and plugins in TinkerClaw — a self-improving OpenClaw fork that's been running 24/7 for months.

Most shopping agents hand you back the first page of Amazon with the prices copied out. This one argues with you about which number matters.

It tries several phrasings of your query, because one keyword is one slice of the catalogue: 8 phrasings returned 268 different products where the best single query gave 66. It parses the size out of the title and ranks on what decides the purchase: €/kg of active ingredient, €/GB, €/kg. The sticker price misleads, and so does Amazon's own per-unit label, which belongs to whichever variant happens to be selected.

Then it checks what most rankers forget: can you buy it? A discontinued listing keeps its page and its price, and would win every ranking. Here it is left out.

Part of TinkerClaw — real-time token tracking, self-improving crons, persistent cognitive memory. This is one piece of that stack; the repo has dozens more.

👉 https://github.com/globalcaos/tinkerclaw

Clone it. Fork it. Break it. Make it yours.

What it does

You give it a keyword, for example "ph minus piscina". It reads the search results on amazon.es, sorts them into kinds, asks at most two questions whose answer would change the result, reads the first ten product pages, and gives you up to three products with the price per useful unit. Only the answer about the form (powder or liquid) filters the list. The other answers, such as "lower the pH" or the amount you need, come back under preferences, and whoever picks from the list applies them.

A product gets a place in that top three only when its page says it is in stock. Products whose stock could not be read come in a separate list, marked unknown and not numbered. If nothing could be verified there is no recommendation, and the answer says so.

Permissions, Data Flow & Consent

Who receives something What When
www.amazon.es and Amazon's image servers Your search words, and requests for product pages and photos, with no account and no cookies Always. With Apify on, Apify reads the pages for start and rank, and only the photos are fetched from here
The LLM client on your machine, and its provider Product titles, up to 4,000 characters of a product page, and the product photo when the title says too little By default, through claude. AMAZON_SHOPPER_LLM_CMD names another client; none turns it off
api.apify.com Your search words and product ids Only with AMAZON_SHOPPER_APIFY_TOKEN, or with apify in KEEPER_SERVICES plus KEEPER_PROXY and a client token (TinkerClaw's Secret Keeper)

Nothing else is contacted, and there is no telemetry.

Money. The pages of amazon.es are free. The LLM client bills its own account, at most one call for the questions and two per product page read. Apify bills its own credit per run. The first call to either prints a line that says what is being sent and how to stop it.

Credentials. None of yours by default. The Apify token or the proxy's client token is read from the environment, sent only to the address it belongs to, and never written down. The LLM client uses its own sign-in, and this skill does not read it.

Files. One SQLite file per task in the temp folder and the output file you name. close deletes the task file after checking that this tool made it, for that task. Another SQLite file that happens to have the name stays, and so do its journals. Photos are never written to disk.

What it cannot do. There is no code for a basket, an order, a login or an account page. It runs no text as code. It does not pose as a browser: it names itself, waits two seconds between page requests, and reports BLOCKED when Amazon refuses.

Other programs. Only the LLM client: claude, llm or ollama. It is found on your PATH, and a copy that another user could have planted or changed is skipped. Nothing but a model name is passed on from the variable.

Text written by sellers. A title or a description can contain instructions meant for an LLM. The client therefore gets no tools (claude is started with an empty tool list, no MCP servers and none of your settings; llm and ollama run have tools only when a flag adds them, and none is passed). The listing is sent as one JSON value, apart from the rules, which say that it is data. The photo goes inside the message and only to claude. Each answer is cut down to the fields and the ranges it may have. The titles in the output are still sellers' words: treat them as data too.

Refund strategy

Amazon's A-to-z Guarantee covers items that are "not as described", so a wrong concentration on the label is a refundable claim. How much work the refund is depends on the seller, and the ranking uses that as a tie-breaker when two products are within 10% of each other:

Tier Who Refund
2 Sold by Amazon, in stock Direct, with a return label
1 Another seller, in stock Covered, but you may have to contact the seller first
0 Seller not known, or stock not verified Higher risk

Above 10% the cheaper one wins.

CLI

Six subcommands, one after the other across the conversation. They need Node 22.5 or newer, for its built-in SQLite:

amazon-shopper start "<keywords>"
amazon-shopper answer <task-id> <q-id> "<answer>"
amazon-shopper rank <task-id>
amazon-shopper inspect <task-id> [--product <asin>]
amazon-shopper set-spec <task-id> <asin> --concentration <pct> [--ingredient <name>] [--source <url>]
amazon-shopper close <task-id>

Every subcommand prints one JSON object on stdout; messages go to stderr.

The state between calls is a SQLite file in the temp folder (Node's node:sqlite). close deletes it. Nothing is remembered from one search to the next.

Typical conversation flow

$ amazon-shopper start "ph minus piscina"
{"task_id":"abc123def456","state":"awaiting_questions","products_count":42,
 "pending_questions":[
   {"id":"form","text":"Powder or liquid?","options":["powder","liquid"],
    "why_load_bearing":"different active ingredients → different €/kg math"},
   {"id":"volume","text":"Annual usage?","options":["<2kg","2-10kg",">10kg"],
    "why_load_bearing":"a 25 kg bag is no bargain if you need 2 kg"}
 ]}

$ amazon-shopper answer abc123def456 form "powder"
{"state":"awaiting_questions","next_question":{...}}

$ amazon-shopper answer abc123def456 volume "2-10kg"
{"state":"ready_to_rank"}

$ amazon-shopper rank abc123def456
{"task_id":"abc123def456","state":"complete",
 "metric":{"metric_id":"eur_per_kg_active","formula_human":"price ÷ kg of active compound (concentration-adjusted)"},
 "top_3":[
   {"asin":"B0...","title":"Bisulfato sódico 98% 5kg granulado","current_price_eur":22.50,
    "package_size_kg":5,"active_ingredient":"sodium bisulfate","concentration_pct":98,
    "spec_source":"title","availability":"available","normalized_metric_value":4.592,"rank_position":1,
    "reasoning_sentence":"Bisulfato sódico 98% 5kg granulado: €22.5 for 5kg @ 98% → 4.59 €/kg-active · ..."},
   ...
 ],
 "needs_concentration_research":[{"asin":"B0...","title":"CTX pH minus 5kg granulado",
    "usual_concentration_pct":100,"reason":"the listing states no strength"}],
 "availability_unknown":[...],
 "unavailable":[{"asin":"B0...","title":"CTX 10kg"}],
 "skipped":[{"asin":"B0...","title":"Generic ph minus","reason":"spec_unknown"}],
 "preferences":{"volume":"2-10kg"}}

$ amazon-shopper close abc123def456
{"ok":true,"task_id":"abc123def456","closed":true}

When there is nothing worth asking, start answers ready_to_rank and you go straight to rank.

Several phrasings at once

scripts/fast-search.mjs runs several phrasings and keeps the cheapest sighting of each product:

node scripts/fast-search.mjs --query "micro sd" \
     --sweep "1tb,1tb a2,512gb,512gb a2,256gb,128gb" --pages 2 --out dataset.json

micro sd 1tb alone found 5 different 1 TB cards; adding 1tb a2 and 1tb v30 u3 took it to 23. These rows come from search pages, which do not state the stock, so open a product before you recommend it. A row also has the delivery text of the search page (delivery_free, delivery_fastest, delivery_tomorrow). Amazon shows it to a visitor with no account, for no address in particular.

How the strength is found

€/kg of active ingredient is what makes powder and liquid comparable, and it needs the strength of each product. It is read from the listing, in this order:

  1. The title ("15%"). A percentage about the price, such as "20% descuento", is not a strength.
  2. The product page, where it names the ingredient with its percentage ("ácido sulfúrico al 15 %").
  3. The LLM client, which reads the page text, or the photo when the title says too little.

Nothing is assumed. A listing that states no strength has none, spec_source says where each number came from, and such a product gets no place in a ranking by active ingredient. It is listed under needs_concentration_research, sometimes with usual_concentration_pct: what that brand's pH minus usually has, from a small table in scripts/brand-concentrations.mjs. That number is a hint to help you decide whether to look further, and it is never used in the ranking.

When the answer could change the winner, look the strength up in whatever way you normally do research, and write it back:

amazon-shopper set-spec <task-id> <asin> --concentration <pct> --ingredient "<name>" --source "<url>"
amazon-shopper rank <task-id>     # ranks again and keeps the confirmed number

A 10 kg bag at €2.40/kg beats every liquid whether it is 92% or 100% pure, so that one is not worth looking up. Never enter a marketing claim as a number, and check whether a figure is per serving or per 100 g before you compare.

When fewer than half of the products state a strength, the list is ranked by package instead (€/L or €/kg), and metric says so. Litres and kilos do not compare with each other: a note appears when the list has both.

Limits in the code

  • At most 2 questions per task (categorize.mjs).
  • At most 10 product pages per task, plus those you confirmed with set-spec (shopper.mjs).
  • One request every 2 seconds, also when several pages are wanted at once (fetch.mjs).
  • One retry after a 5xx answer, none after a CAPTCHA (fetch.mjs).

Reading the live amazon.es DOM

The extraction rules below were measured against live pages and are the difference between a plausible answer and a correct one.

field where it really is
title id="productTitle"
total price Inside corePriceDisplay_desktop_feature_div, the only digit-bearing a-offscreen is the price-per-unit. Strip tags on that block and take the FIRST NN,NN € in the resulting text for the total; Amazon's own X,XX € por kg line sits right after it and is a free cross-check. Getting this backwards reported a 2.5 kg tub as €25.46 instead of €63.65 — a 2.5× error that looked plausible
€/kg perunit-accessibility-label → 25,46&nbsp;&euro; por kg. Cross-check total / size ≈ unit; a mismatch means the page is showing another variant
stock the id="availability" blocks, one per buying option, often with an empty one at the end. The first with text decides: En stock / Sólo queda(n) N en stock = buyable; all of them EMPTY = out of stock
image data-a-dynamic-image anchored on id="landingImage" (the first match in the document is a different block and fails to parse). It is a JSON map of URL → [w,h]; sort by area for the hi-res, strip the ._AC_SY355_.-style modifier for the original, re-add ._SX200_. for a thumbnail. og:image is the fallback

Do NOT use 'outOfStock' in html as the stock test — that string appears in inline JS on every page and marked all 11 candidates dead in one sweep.

Any per-unit price ~10× better than its peers is a parse bug until proven otherwise. An "SD2Vita adapter, supports microSD 256GB" at €6.95 scored 0.027 €/GB and ranked as the best buy on the board: accessories quote a supported capacity, not one they store. sdcard-spec.mjs:isAccessory() and the "supports/up to" context check exist for exactly this.

PRICE PRESENT ≠ IN STOCK

The intuitive rule — "if a product has the price, then it is in stock" — does not hold on amazon.es. Two ASINs confirmed unavailable (B07ZV1MGSZ, B00MNNE7HE) both still render a price — €34,99 and €86,99 — sourced from "Otros vendedores" / used offers, while carrying No disponible, an empty #availability block and no buy-now-button. A price string is necessary but not sufficient. The #availability block is the signal that decides; require non-empty text matching En stock|Sólo queda|Disponible.

What to tell the user

Give every product six things: the link, the picture, the price in €, the price per useful unit, what is being optimised, in words, and whether it can be bought. Sort by the price per unit. If that number could not be computed, say so in the row; it is not the cheapest.

Stock comes before everything else.

  • Recommend only from top_3. Its products had En stock or a stated number left when the page was read.
  • availability_unknown is a list to check by hand. Show it as that, with "stock not checked" on every row, and do not pick a winner from it.
  • A live page with a title and a price does not prove that the product is for sale. Amazon's own brands (Amazon Basics, Solimo, by Amazon) rank well and are often discontinued with the page left standing.

Memory cards

scripts/sdcard-spec.mjs reads the markings (A1/A2, U1/U3, V10…V90, C10, bus, pack count) and turns them into a tier. €/GB alone is misleading for storage: two 128 GB cards at the same price can differ by ten times in sustained writing, and for the system disk of a Raspberry Pi the A class matters more than the big "MB/s" on the front. That number is a read speed, so a card that states nothing else is Unrated.

node scripts/sdcard-stock.mjs dataset.json checked.json --per-size 5   # reads the product pages, 2 s each
node scripts/sdcard-chart.mjs checked.json chart.html

sdcard-stock.mjs opens the cheapest cards of each size and writes down whether they can be bought and when it looked. sdcard-chart.mjs draws and picks only from cards that were in stock then, in the colours of the tiers, every point a link to its product. The rest is listed below the chart as not checked. --only-tomorrow keeps the cards whose search page showed delivery the next day.

When it does not work

What happened Result
Amazon shows a CAPTCHA State blocked, reason captcha. No retry
HTTP 5xx One retry, then blocked, reason rate-limit
Amazon's browser check (HTTP 202) blocked, reason http-202. It comes and goes; trying later is reasonable
No results complete, with an empty top_3
No stock could be read complete, empty top_3, reason no product with verified stock
The spec is nowhere The product is listed under skipped as spec_unknown
The listing states no strength Listed under needs_concentration_research; ranked by package only
The LLM client fails on the first call The command stops with the error. No other client is tried

A blocked run says blocked. The alternatives are to try later, to set up Apify, or to tell the user that amazon.es refused.

Optional: Apify

Apify runs a scraper for you and can answer when a plain request is refused:

export AMAZON_SHOPPER_APIFY_TOKEN="<from https://console.apify.com/settings/integrations>"

When it is set, the skill uses it for search and product pages, and not its own requests. The scraper is always junglee/amazon-crawler and the shop is always amazon.es; no variable changes either. A run costs a few cents of your Apify credit.

If you run TinkerClaw's Secret Keeper, put apify in KEEPER_SERVICES, the proxy's loopback address in KEEPER_PROXY and a client token in KEEPER_TOKEN_SHOPPER. The proxy then adds the Apify token, and this program never holds it. Take apify out of the list to switch it off.

Tests

node --experimental-sqlite --test tests/*.test.mjs tests/adapters/*.test.mjs

They run offline, with canned pages and canned LLM answers. Read tests/package-surface.test.mjs first: it fails if a login, a cookie, a keychain call, another host or another store gets back into the code. tests/availability.test.mjs holds the stock rule.

scripts/dev-capture-fixtures.mjs refreshes the saved pages: one search and one product page from amazon.es.

Changelog

  • 1.2.4 — A strength the listing did not state was filled in from the ingredient, the brand or the form (22% for hydrochloric acid, 95% for any granules) and ranked as if it had been read. Now only a stated or confirmed strength counts. The memory-card chart picked from cards nobody had checked; it now needs sdcard-stock.mjs first, for prepared datasets too. close deleted any SQLite file with the right name; it now deletes only the task file this tool made, and a wrong task id no longer creates a file. A direction answer ("raise", "lower") filtered the list; it comes back under preferences. The LLM client runs with no tools and gets listing text as data only. For that reason gemini, oracle and openclaw are no longer accepted, nor any argument except the model. Also fixed: a product without a price ranked as free, and a strength read from the page text was not used. A task file made by 1.2.3 has no mark, so close leaves it: delete it by hand.
  • 1.2.3 — An out-of-stock product could be recommended: stock only lowered a tie-breaker, and a missing stock field from Apify counted as "in stock". Now only verified stock is ranked, the rest is listed apart, and the product page's own stock line is read. Removed, because they did not work or did not match this page: the "Creators API" source (it sent its requests to the older PA-API 5, which Amazon has deprecated), the search outside Amazon (its page check refused every page that was not Amazon's, so it never returned anything), the other Amazon marketplaces, cookies, the call to a gateway method that does not exist before the LLM client, and the photo comparison with ImageMagick, which no command used. Fixed: four page reads at once ignored the two-second pause; a read speed was taken as a write speed for memory cards; a task could not be ranked again after set-spec; product photos now use the same checked connection as pages. New: AMAZON_SHOPPER_LLM_CMD=none.
  • 1.2.2 — Pages and redirects are checked on every hop, and programs are started from trusted folders only. Apify calls can go through a local credential proxy.
  • 1.2.1 — Removed the login, the stored session, the browser relay, the other shops and the metric that ran text as code.
  • 1.2.0 — Security fixes after an outside review.