Files
pinterest-scraper/README.md
T

44 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Pinterest 关键词图片爬取工具
通过 CDP 协议连接本地浏览器,按关键词搜索 Pinterest 并下载最高分辨率的图片。
## 前置条件
本地浏览器需开启 CDP 调试端口(WebSocket 端点),例如 Chrome
```bash
chrome.exe --remote-debugging-port=9222
```
## 使用方法
```bash
uv sync # 安装依赖
uv run pinterest_image_capture.py "风景壁纸"
```
### 参数
| 参数 | 说明 | 默认值 |
|------|------|--------|
| `keyword` | 搜索关键词(必填,位置参数) | - |
| `-n, --count` | 爬取图片数量 | 40 |
| `--proxy` | 下载图片使用的代理,传空字符串禁用 | `http://127.0.0.1:7892` |
| `--cdp` | CDP 接口地址 | `ws://127.0.0.1:9222/devtools/browser` |
| `-o, --output` | 保存目录 | `output/img/<关键词>` |
### 示例
```bash
# 爬取 20 张 "anime wallpaper",禁用代理
uv run pinterest_image_capture.py "anime wallpaper" -n 20 --proxy ""
# 指定 CDP 地址和保存目录
uv run pinterest_image_capture.py 猫 -n 10 --cdp "http://127.0.0.1:9222" -o D:/pics
```
## 说明
- 连续 10 轮滚动无新图片时自动停止(搜索结果不足目标数量时不会死循环)。
- 下载阶段并发数为 10,走 `--proxy` 指定的代理。