Amazon Search — 亚马逊搜索
v0.1.1搜索Amazon产品列表中的关键词并返回结构化的JSON结果。结果通过ASIN/uuid缓存以实现增量搜索,并自动保存到`results/`目录中。
运行时依赖
安装命令
点击复制技能文档
Amazon 搜索技能 搜索 Amazon 产品,匹配关键字查询,并返回结构化的 JSON 结果。
前提条件 安装 Bun 运行时:curl -fsSL https://bun.sh/install | bash 安装技能依赖项:cd skills/amazon-search bun install 安装 Playwright 浏览器(用于 Amazon 搜索):cd skills/amazon-search/scripts npm install npx playwright install chromium
Cookie 此技能使用 Playwright 直接在无头浏览器中搜索 Amazon。不需要手动 cookie 管理。
Playwright 前提条件 安装 npm 依赖项和 Playwright 浏览器:cd skills/amazon-search/scripts npm install npx playwright install chromium
输入 参数 类型 描述 keyword string 搜索关键字(例如 "t-shirt") proxy string 可选代理 URL。可以作为参数值或通过 --proxy 标志 / T2P_PROXY 环境变量设置。支持 HTTP/HTTPS 和 SOCKS5 代理。 price_min number 可选最低价格过滤器。映射到 Amazon 低价。 price_max number 可选最高价格过滤器。映射到 Amazon 高价。 --pages number 最大页面数(默认:1)。每页有 ~20-60 个结果。 --num-products number 最大产品数。达到限制后停止,即使还有更多页面可用。 --incremental 标志 只输出新结果,这些结果之前没有缓存。 --clear-cache 标志 清除此关键字的缓存,然后搜索。 --output string 自定义输出目录(默认:results/)。 --download 标志 搜索完成后使用 @t2p/image-cache 下载产品图像。
输出格式 返回一个 JSON 对象,包含搜索元数据和 Amazon 产品对象数组。结果自动保存到 results/__.json。 { "keyword": "shirt", "timestamp": "2026-04-06T12:34:56.789Z", "count": 10, "items": [ { "id_": "B09TPN9NJ6", "uuid": "418e2c7d-ccaa-4ca3-9d1b-6b4f3bd406b0", "original_image_url": "https://m.media-amazon.com/images/I/91YprRrDB4L._AC_UL960_FMwebp_QL65_.jpg", "title": "Amazon Essentials Men's Slim-Fit Crewneck T-Shirts, Short Sleeve", "item_page": "https://www.amazon.com/dp/B09TPN9NJ6", "rating": 4.4, "review_count": 1787, "price": "$19.99", "description": "Amazon Essentials Men's Slim-Fit Crewneck T-Shirts, Short Sleeve" } ] }
项目字段 字段 类型 描述 id_ string Amazon ASIN(Amazon 标准识别号) uuid string 来自 Amazon 数据属性的唯一标识符 original_image_url string 产品图像 URL(最高分辨率来自 srcset) title string 产品标题 item_page string 产品页面的完整 URL rating number 平均评分(1-5) review_count number 评论数量 price string 价格(包括货币) description string 产品描述(可能与标题相同,如果没有单独的描述)
执行 使用 scripts/amazon_search.ts 脚本。所有 TypeScript 文件必须使用 Bun 运行: # 简单搜索 bun run scripts/amazon_search.ts "shirt"
配置工具 使用 scripts/configure.ts 生成环境变量命令并管理缓存: # 生成代理设置命令(复制并运行输出) bun run scripts/configure.ts proxy "http://127.0.0.1:7890" # 列出缓存文件 bun run scripts/configure.ts listcache # 清除特定关键字的缓存 bun run scripts/configure.ts clearcache "shirt" # 清除所有缓存 bun run scripts/configure.ts clearcache --all
使用注意事项 运行时:所有 TypeScript 文件必须使用 bun run 运行 搜索方法:使用 Playwright 直接在无头浏览器中搜索 Amazon(无需手动 cookie 管理) 代理支持:代理从 T2P_PROXY 环境变量(或 --proxy CLI 标志)读取。支持 HTTP/HTTPS 和 SOCKS5 代理(例如 socks5://127.0.0.1:1080)。 缓存和去重:搜索结果缓存到 resultscache/_cache.md。每行是一个 ASIN/uuid,用于去重。 增量模式:使用 --incremental 输出仅新结果,这些结果之前没有缓存。 清除缓存:使用 --clear-cache 删除此关键字缓存,然后搜索,或使用 scripts/configure.ts clearcache。 自定义输出:使用 --output=/path/to/dir 将结果保存到自定义目录。 下载图像:使用 --download 自动下载产品图像,使用 @t2p/image-cache,在搜索完成后。
示例 所有命令使用 bun run: # 简单搜索 bun run scripts/amazon_search.ts "t-shirt" # 增量搜索 - 仅输出新结果,不在缓存中 bun run scripts/amazon_search.ts "t-shirt" --incremental # 清除缓存,然后搜索 bun run scripts/amazon_search.ts "t-shirt" --clear-cache --incremental # 使用代理 bun run scripts/amazon_search.ts "t-shirt" --incremental --proxy "http://127.0.0.1:10809" # 多页搜索(获取 2 页,~40-120 个结果) bun run scripts/amazon_search.ts "t-shirt" --pages=2 # 多页 + 增量(仅新项来自所有页面) bun run scripts/amazon_search.ts "t-shirt" --pages=2 --incremental