Xpersona
B

bing图片批量下载skill

CLAWHUB · Unverified

当用户需要按关键词批量下载图片、从 Bing 或多个图片来源收集候选、保存图片到本地目录、避免重复下载,或希望复用当前仓库里的现成图片下载流程时使用。遇到类似“帮我按关键词下载 10 张图片”“批量抓取 Bing 图片并保存到本地”“从多个来源收集图片候选再下载”“需要下载摘要和保存目录”这类请求时,应主动使用这...

62
Rank
84
Safety
1.2k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.2K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17afqafc9cxg79k2at04c4ydd83gnaq:image-downloader
  1. Install using `clawhub skill install s17afqafc9cxg79k2at04c4ydd83gnaq:image-downloader` in an isolated environment before connecting it to live workloads.
  2. No published capability contract is available yet, so validate auth and request/response behavior manually.
  3. Review the upstream CLAWHUB listing at https://clawhub.ai/16miku/image-downloader before using production credentials.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-16miku-image-downloader/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

144,547 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: image-downloader
description: 当用户需要按关键词批量下载图片、从 Bing 或多个图片来源收集候选、保存图片到本地目录、避免重复下载,或希望复用当前仓库里的现成图片下载流程时使用。遇到类似“帮我按关键词下载 10 张图片”“批量抓取 Bing 图片并保存到本地”“从多个来源收集图片候选再下载”“需要下载摘要和保存目录”这类请求时,应主动使用这个 skill。
---

# 多来源关键词图片批量下载

这个 skill 用于复用当前目录中的 `scripts/bing_image_downloader.py` 脚本,让其他 agent 能稳定完成“按关键词从多个来源收集候选并下载图片到本地”的任务。

## 项目链接

- GitHub 仓库:https://github.com/16Miku/image-downloader-skill
- ClawHub 页面:https://clawhub.ai/16miku/image-downloader

## 何时使用
当用户明确提出以下类型需求时,优先使用本 skill:
- 按关键词批量下载公开图片到本地
- 想从 Bing 或当前脚本支持的多个来源收集图片候选
- 想保存 10、50、100 张关键词图片到本地目录
- 想通过增加页数或扩大候选池来提高最终成功数量
- 想复用现成脚本执行下载,并拿到保存目录、成功数量和运行摘要
- 想避免重复下载之前已经保存过的内容

如果用户要的是:
- 其他搜索引擎或站点的专用下载器开发
- 图像识别、分类、审核、打标
- 非关键词方式(例如固定页面 URL 批量抓取)

则这个 skill 不是最佳选择。

## 依赖文件
- 主脚本:`scripts/bing_image_downloader.py`
- 测试文件:`tests/test_bing_image_downloader.py`
- 集成测试:`tests/test_integration_multisource.py`

## 工作流程
按下面顺序执行:

1. 读取用户需求中的关键词、目标数量、页数。
2. 如果用户没给页数,按下面经验值选择:
   - 10 张:`--pages 3`
   - 50 张:`--pages 5`
   - 100 张:`--pages 10`
3. 运行脚本:
   - 如果当前环境有 `uv`,使用 `uv run --with requests python` 运行。
   - 如果没有 `uv`(例如服务器、容器、OpenClaw Agent),直接使用 `python3` 运行,需确保 `requests` 已安装。
4. 检查输出中:
   - 成功下载数量
   - 候选总数与去重后数量
   - 来源统计
   - 失败原因(常见为 403、SSL、超时)
5. 向用户汇报:
   - 实际保存目录
   - 成功数量
   - 是否达到目标数量
   - 当前来源统计
   - 如未达标,说明通常是第三方源站拒绝访问、超时或链接失效,而非脚本崩溃

## 推荐命令模板

### 有 uv 环境

#### 下载 10 张
```bash
uv run --with requests python "scripts/bing_image_downloader.py" "cat" --limit 10 --pages 3
```

#### 下载 50 张
```bash
uv run --with requests python "scripts/bing_image_downloader.py" "cat" --limit 50 --pages 5
```

#### 下载 100 张
```bash
uv run --with requests python "scripts/bing_image_downloader.py" "cat" --limit 100 --pages 10
```

### 无 uv 环境(服务器 / OpenClaw Agent)

```bash
python3 "scripts/bing_image_downloader.py" "cat" --limit 10 --pages 3
```

## 参数映射规则
- 用户说“下载 10 张” → `--limit 10`
- 用户说“下载 50 张” → `--limit 50`
- 用户说“下载 100 张” → `--limit 100`
- 用户没说页数时,按上面的推荐默认值设置 `--pages`
- 用户明确给出页数时,尊重用户输入

## 输出说明
脚本会把结果保存到:
```text
downloads/<关键词>/
```

例如关键词 `cat` 会保存到:
```text
downloads/cat/
```

文件名按顺序编号,例如:
- `001.jpg`
- `002.jpg`
- `003.png`

此外,脚本会记录下载元数据与历史索引,用于后续运行时跳过已下载过的候选内容。

## 常见问题解释
### 为什么会出现下载失败?
因为搜索结果中的原图通常来自第三方网站,不是都由当前来源自己托管。第三方站点可能拒绝脚本访问,常见错误:
- `403 Forbidden`
- SSL 证书错误
- 连接超时
- 404 Not Found

### 为什么加大 `--pages` 后下载数量会提高?
因为脚本会抓更多结果页,收集更大的候选链接池。即使其中一部分链接失效,仍然可以用后面的候选补位。

## 给用户的汇报模板
完成后可按下面结构回复用户:

```text
已执行关键词图片批量下载。
- 关键词:<关键词>
- 目标数量:<limit>
- 抓取页数:<pages>
- 候选总数:<候选数量>
- 去重后数量:<去重后数量>
- 实际成功下载:<成功数量>
- 来源统计:<来源统计>
- 保存目录:downloads/<关键词>/

如果存在失败链接,通常是第三方图片源拒绝访问、超时或链接失效,不影响脚本继续补充后续候选。
```

## 注意事项
- 这是一个“按关键词下载公开图片”的现成流程复用 skill,当前来源至少包含 Bing,不要把它表述成通用全网图片下载器。
- 优先复用现有脚本,不要重复手写新下载器,除非用户明确要求修改或升级脚本。
- 当用户要求“提高下载数量”时,优先建议增加 `--pages` 或扩大候选池,而不是先改成并发下载。
- 当用户提到”不想重复下载”时,应明确说明当前流程支持基于历史索引跳过重复候选。

## OpenClaw Agent 定时任务

本 skill 已在 OpenClaw Agent 上完成实际验证,支持通过 cron 定时任务自动下载图片并发送到飞书。

### 定时任务执行流程

1. 设置 `PATH` 和 `bash` 严格模式
2. 检查 Python 和 `requests` 环境
3. 执行图片下载脚本
4. 检查下载目录中的图片文件
5. 

README.md

# image-downloader

一个基于 Python 的多来源关键词图片下载项目,同时也整理成了一个可供其他 agent 复用的 Claude skill。

## 项目链接

- GitHub 仓库:https://github.com/16Miku/image-downloader-skill
- ClawHub 页面:https://clawhub.ai/16miku/image-downloader

它当前的核心能力是:
- 按关键词从多个来源收集图片候选(当前支持 Bing 和 DemoSource)
- 通过分页收集更大的候选池
- 对候选进行基础去重
- 顺序下载图片到本地目录
- 记录下载元数据与历史索引,避免重复下载
- 输出本次运行的来源统计与下载摘要

## 项目用途

这个项目适合以下场景:
- 学习关键词图片抓取的基本流程
- 学习如何从搜索结果页中提取候选资源链接
- 学习如何通过分页扩大候选池,提高总下载成功数量
- 学习如何记录下载元数据与历史索引,避免重复下载
- 作为一个可复用 skill,交给其他 agent 按关键词执行多来源图片批量下载任务

## 目录结构

```text
image-downloader/
├── .gitignore
├── README.md
├── SKILL.md
├── evals/
│   └── evals.json
├── image_downloader/
│   ├── reporting.py
│   ├── storage.py
│   └── sources/
│       ├── bing.py
│       └── demo.py
├── scripts/
│   └── bing_image_downloader.py
└── tests/
    ├── test_bing_image_downloader.py
    └── test_integration_multisource.py
```

说明:
- `SKILL.md`:skill 的说明文档,定义何时触发、如何执行、如何汇报结果
- `scripts/bing_image_downloader.py`:CLI 主脚本,负责组织多来源收集、去重、下载与摘要输出
- `image_downloader/sources/`:不同来源的候选收集实现
- `image_downloader/storage.py`:下载记录、历史索引与重复跳过逻辑
- `image_downloader/reporting.py`:运行摘要构建
- `tests/test_bing_image_downloader.py`:主脚本与基础行为测试
- `tests/test_integration_multisource.py`:多来源流程集成测试
- `evals/evals.json`:skill 的示例评测用例
- `downloads/`:运行时生成的图片目录,已被 `.gitignore` 忽略,不纳入版本控制

## 环境要求

- Python 3
- `requests`
- [uv](https://github.com/astral-sh/uv)(可选)

本项目默认使用 `uv` 运行,不要求你提前全局安装依赖。

如果当前环境没有 `uv`(例如服务器、容器、OpenClaw Agent 等场景),可以直接使用 `python3` + `requests` 运行:

```bash
python3 -c "import requests; print(requests.__version__)"  # 确认 requests 已安装
python3 "scripts/bing_image_downloader.py" "cat" --limit 10 --pages 3
```

如果 `requests` 未安装:

```bash
python3 -m pip install requests
```

## 快速开始

在项目根目录执行。

### 下载 10 张图片

```bash
uv run --with requests python "scripts/bing_image_downloader.py" "cat" --limit 10 --pages 3
```

### 下载 50 张图片

```bash
uv run --with requests python "scripts/bing_image_downloader.py" "cat" --limit 50 --pages 5
```

### 下载 100 张图片

```bash
uv run --with requests python "scripts/bing_image_downloader.py" "cat" --limit 100 --pages 10
```

## 参数说明

- `keyword`:搜索关键词,例如 `cat`、`dog`、`landscape`
- `--limit`:目标下载数量
- `--pages`:抓取各来源候选时使用的结果页数,用来扩大候选池

推荐经验值:
- 10 张:`--pages 3`
- 50 张:`--pages 5`
- 100 张:`--pages 10`

如果你更看重“尽量下载满目标数量”,通常优先增加 `--pages`,而不是先改成并发下载。

当前 CLI 会固定使用 `bing` 和 `demo` 两个来源执行候选收集。

## 工作原理

脚本主要分为 4 个步骤:

1. 调用多个来源收集关键词图片候选(当前支持 Bing 和 DemoSource)
2. 合并候选并按图片 URL 做基础去重
3. 结合历史索引跳过此前已下载过的内容
4. 逐个尝试下载,并输出来源统计与本次运行摘要

为了提高总下载数量,脚本不会只依赖单页结果,而是会:
- 对每个来源按页抓取更多结果,扩大候选池
- 合并多个来源返回的候选内容
- 去重后顺序尝试下载,失败就跳过,继续使用后续候选补位
- 对已下载过的候选进行跳过,避免重复保存

这也是它比“只抓一页、只用单一来源再下载”的做法更容易下载满目标数量的原因。

## 输出位置

图片会保存到:

```text
downloads/<关键词>/
```

例如下载 `cat`:

```text
downloads/cat/
```

文件名按顺序编号,例如:
- `001.jpg`
- `002.jpg`
- `003.png`

目录下还会记录下载元数据与历史索引,供后续运行时判断是否应跳过重复候选。

## 常见失败原因

搜索结果中的原图通常来自第三方网站,而不是都由当前来源自己托管,因此常见失败并不意味着脚本崩溃。

常见原因包括:
- `403 Forbidden`
- SSL 证书错误
- 连接超时
- `404 Not Found`

这类失败出现时,脚本会继续尝试后续候选链接。

## 运行测试

#

_meta.json

{
  "ownerId": "kn7fspy0bn2brek0j28qw39wn5826za8",
  "slug": "image-downloader",
  "version": "2.0.1",
  "publishedAt": 1776049098449
}

CLAUDE.md

# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## 当前仓库状态

- 当前项目根目录已经是多来源图片下载器的主线实现。
- 根目录包含 `image_downloader/` 模块、`scripts/bing_image_downloader.py` CLI 入口,以及模型、来源、存储、摘要和集成测试。
- 处理任务时默认以根目录当前实现为准,不再把它描述成“只有 Bing 单来源”的旧版本。

## 环境与执行约定

- 当前系统的 Python 使用 `uv` 进行管理。
- 涉及 Python 运行、依赖安装、测试执行时,优先使用 `uv`。
- 根目录目前没有 `pyproject.toml`;常用方式是直接用 `uv run --with requests python ...` 运行脚本或测试。

## 提交约定

- 本仓库进行 git 提交时,提交信息使用中文。

## 常用命令

### 运行主脚本

在项目根目录运行多来源图片下载器:

```bash
uv run --with requests python "scripts/bing_image_downloader.py" "cat" --limit 10 --pages 3
```

更大下载量时,按 README 中的经验值优先增加 `--pages`:

```bash
uv run --with requests python "scripts/bing_image_downloader.py" "cat" --limit 50 --pages 5
uv run --with requests python "scripts/bing_image_downloader.py" "cat" --limit 100 --pages 10
```

### 运行测试

运行当前根目录完整测试集:

```bash
uv run --with requests python -m unittest tests.test_bing_image_downloader tests.test_models_and_sources tests.test_storage tests.test_integration_multisource -v
```

运行单个测试模块时,可用 `unittest` 的点路径:

```bash
uv run --with requests python -m unittest tests.test_storage
```

如果要运行单个测试方法,也可继续使用 `unittest` 的点路径:

```bash
uv run --with requests python -m unittest tests.test_bing_image_downloader.TestBingImageDownloader.test_collect_image_urls_across_multiple_pages
```

### 冒烟验证

```bash
uv run --with requests python "scripts/bing_image_downloader.py" "cat" --limit 10 --pages 3
```

## 根目录代码架构

### 主脚本

- `scripts/bing_image_downloader.py`
  - 这是当前根目录的 CLI 入口。
  - 它负责组织多来源候选收集、候选去重、历史索引跳过、顺序下载和运行摘要输出。

### 主要模块

- `image_downloader/models.py`
  - 定义统一候选与记录模型。
- `image_downloader/sources/`
  - 提供来源接口以及 `bing`、`demo` 等来源实现。
- `image_downloader/storage.py`
  - 负责下载记录、历史索引与重复跳过。
- `image_downloader/reporting.py`
  - 负责构建运行摘要文本。

### 测试结构

当前根目录实现包含 4 个测试模块:

- `tests/test_bing_image_downloader.py`
  - 覆盖 CLI、兼容接口与主流程行为。
- `tests/test_models_and_sources.py`
  - 覆盖统一模型与来源接口。
- `tests/test_storage.py`
  - 覆盖存储、索引与历史去重逻辑。
- `tests/test_integration_multisource.py`
  - 覆盖多来源集成流程与摘要行为。

## README / SKILL 对齐提醒

来自 `README.md` 与 `SKILL.md` 的关键约定:

- 根目录当前实现已经完成多来源 MVP。
- 输出目录固定为 `downloads/<关键词>/`。
- 当目标数量较大时,优先增加 `--pages`,而不是先改并发。
- 常见失败通常来自第三方源站不可访问,例如:`403`、SSL 错误、超时、`404`;这不一定表示脚本主流程崩溃。
- `demo` 来源主要用于统一接口与失败容错验证,不应表述为稳定真实图片来源。

## 仓库内已确认不存在的配置

以下文件在当前根目录下未发现:

- `.cursorrules`
- `.cursor/rules/**`
- `.github/copilot-instructions.md`
- `pyproject.toml`

因此当前开发信息主要以 `README.md`、脚本源码、测试文件和项目内 worktree 结构为准。

docs/superpowers/plans/2026-04-10-multi-source-image-downloader.md

# Multi-Source Image Downloader Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** 将当前 Bing 专用图片下载脚本重构为一个支持统一来源接口、标准去重、历史索引和基础多来源调度的关键词图片下载器。

**Architecture:** 保留单一 CLI 入口,但将实现拆分为统一数据模型、来源模块、下载存储和报告模块。第一阶段只落地 BingSource 与 DemoSource,通过标准去重和历史索引解决重复下载问题,并为后续接入更多真实来源保留清晰边界。

**Tech Stack:** Python 3、requests、argparse、pathlib、hashlib、json、unittest、unittest.mock、uv

**当前状态(2026-04-10):** 当前根目录实现已经完成多来源 MVP:支持多来源候选收集、历史去重、续写编号与运行摘要。`demo` 来源当前主要用于统一接口与失败容错验证,不作为稳定真实来源承诺;后续重点转向文档、skill、评测与来源扩展,而不是继续补齐基础 MVP 能力。

---

## 文件结构映射

### 计划新增文件

- `D:/0/7/scrape/bing-keyword-image-downloader/image_downloader/__init__.py`
  - 包入口,标记新的模块化实现目录。
- `D:/0/7/scrape/bing-keyword-image-downloader/image_downloader/models.py`
  - 定义统一数据模型,例如 `ImageCandidate`、`DownloadRecord`、`RunStats`。
- `D:/0/7/scrape/bing-keyword-image-downloader/image_downloader/sources/__init__.py`
  - 来源模块包入口。
- `D:/0/7/scrape/bing-keyword-image-downloader/image_downloader/sources/base.py`
  - 定义统一来源接口,例如 `BaseSource`。
- `D:/0/7/scrape/bing-keyword-image-downloader/image_downloader/sources/bing.py`
  - 承载 Bing 抓取逻辑,从旧脚本迁移提取与分页采集能力。
- `D:/0/7/scrape/bing-keyword-image-downloader/image_downloader/sources/demo.py`
  - 提供无网络依赖的示例来源,便于测试统一接口与容错行为。
- `D:/0/7/scrape/bing-keyword-image-downloader/image_downloader/storage.py`
  - 承载文件保存、内容 hash、索引读写、元数据记录能力。
- `D:/0/7/scrape/bing-keyword-image-downloader/image_downloader/reporting.py`
  - 负责生成运行结果摘要与统计信息。
- `D:/0/7/scrape/bing-keyword-image-downloader/tests/test_models_and_sources.py`
  - 覆盖统一模型与来源接口的基础测试。
- `D:/0/7/scrape/bing-keyword-image-downloader/tests/test_storage.py`
  - 覆盖文件 hash、索引写入、历史去重和元数据保存。
- `D:/0/7/scrape/bing-keyword-image-downloader/tests/test_integration_multisource.py`
  - 覆盖多来源整合流程的集成测试。

### 计划修改文件

- `D:/0/7/scrape/bing-keyword-image-downloader/scripts/bing_image_downloader.py`
  - 从单体脚本改为新的 CLI 入口,负责参数解析、来源调度、调用 pipeline / storage / reporting。
- `D:/0/7/scrape/bing-keyword-image-downloader/tests/test_bing_image_downloader.py`
  - 调整为更轻量的 CLI / 兼容性测试,避免继续把全部逻辑塞在单文件测试中。
- `D:/0/7/scrape/bing-keyword-image-downloader/README.md`
  - 更新为多来源下载器说明。
- `D:/0/7/scrape/bing-keyword-image-downloader/SKILL.md`
  - 更新为多来源 skill 说明。
- `D:/0/7/scrape/bing-keyword-image-downloader/evals/evals.json`
  - 增加多来源与去重相关评测场景。

### 关键拆分原则

1. `sources/` 只负责发现候选,不负责最终保留决策。
2. 候选合并、URL 规范化、基础去重和目标截断已由当前 CLI 与现有模块吸收,不再要求单独落地 `pipeline.py`。
3. `storage.py` 只负责落盘、计算 hash、索引和元数据,不解析来源页面。
4. `reporting.py` 只负责统计和输出文本,不修改业务数据。
5. CLI 入口只负责调度,不在入口内堆叠具体策略。

---

### Task 1: 建立统一模型与来源接口

**Files:**
- Create: `D:/0/7/scrape/bing-keyword-image-downloader/image_downloader/__init__.py`
- Create: `D:/0/7/scrape/bing-keyword-image-downloader/image_downloader/models.py`
- Create: `D:/0/7/scrape/bing-keyword-image-downloader/image_downloader/sources/__init__.py`
- Create: `

Sponsored

Ads related to bing图片批量下载skill and adjacent AI workflows.