关于 jina-cli
jina-cli 是用于读取网页内容和进行 AI 网页搜索的命令行工具,面向需要将网页信息用于研究或 LLM 工作流的人。它支持批量读取、内容格式选择、站点筛选和配置管理。
主要功能
- 01提取 URL 网页内容
- 02AI 处理搜索结果
- 03批量读取 URL
- 04Markdown、HTML、文本等格式
- 05按站点筛选搜索
- 06管理配置与代理
适用场景
- 01将网页文章转换为便于 LLM 使用的内容
- 02搜索主题并获取结果内容
- 03批量处理网址清单
- 04读取带图片的社交媒体帖子
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ geekjourneyx/ jina-cli --skill jina-cli安装后在 Claude Code 中输入/jina-cli确认已加载。
详细介绍
jina - 网页内容阅读器与搜索
用于阅读网页内容和执行 AI 驱动的网页搜索的命令行工具。
快速开始
安装:
curl -fsSL https://raw.githubusercontent.com/geekjourneyx/jina-cli/main/scripts/install.sh | bash
基本用法:
# Read a URL
jina read --url "https://example.com"
# Search the web
jina search --query "golang latest news"
命令
| 命令 | 用途 |
|---|---|
read | 从 URL 提取内容并转换为适合大模型的格式 |
search | 通过 AI 驱动的结果处理来搜索网页 |
config | 管理设置(set/get/list/path) |
Read 命令
从任意 URL 提取内容:
# Basic read
jina read --url "https://example.com"
# Read with image captioning
jina read -u "https://x.com/user/status/123" --with-alt
# Batch process from file
jina read --file urls.txt
# Output as Markdown
jina read -u "https://example.com" --output markdown
# Save to file
jina read -u "https://example.com" --output-file result.md
响应格式
API 可通过 --format 以不同格式返回内容:
markdown- 默认格式,适合大模型的 Markdownhtml- 原始 HTMLtext- 纯文本screenshot- 截图的 URL
高级选项
# Bypass cache
jina read -u "https://example.com" --no-cache
# Use proxy
jina read -u "https://example.com" --proxy "http://proxy.com:8080"
# CSS selector extraction
jina read -u "https://example.com" --target-selector "article.main"
# Wait for element to load
jina read -u "https://example.com" --wait-for-selector "#content"
# Forward cookies
jina read -u "https://example.com" --cookie "session=abc123"
# POST method for SPA with hash routing
jina read -u "https://example.com/#/route" --post
Search 命令
搜索网页并自动获取排名靠前结果的内容:
# Basic search
jina search --query "golang latest news"
# Restrict to specific sites
jina search -q "AI developments" --site techcrunch.com --site theverge.com
# Limit results
jina search -q "climate change" --limit 10
# Output format
jina search -q "news" --output markdown
站点过滤
使用多个 --site 标志,将搜索范围限制为特定域名:
jina search -q "startup funding" --site techcrunch.com --site theverge.com --site wired.com
配置
配置文件:~/.jina-reader/config.yaml
优先级:命令参数 > 环境变量 > 配置文件 > 默认值
环境变量:
JINA_API_BASE_URL- Read API URL(默认:https://r.jina.ai/)JINA_SEARCH_API_URL- Search API URL(默认:https://s.jina.ai/)JINA_TIMEOUT- 请求超时时间,单位为秒(默认:30)JINA_WITH_GENERATED_ALT- 启用图像说明生成(默认:false)JINA_OUTPUT_FORMAT- 输出格式:json/markdown(默认:json)JINA_PROXY_URL- 代理服务 URL
配置命令:
# Set configuration
jina config set timeout 60
jina config set with-generated-alt true
# View configuration
jina config list
jina config get timeout
jina config path
输出格式
JSON 格式(默认,机器可读):
{
"success": true,
"data": {
"url": "https://example.com",
"content": "# Extracted Content\n\n...",
"title": "Page Title"
}
}
Markdown 格式(人类可读):
jina read -u "https://example.com" --output markdown
常见用例
阅读社交媒体帖子
# X (Twitter) posts
jina read -u "https://x.com/elonmusk/status/123456" --with-alt
# The --with-alt flag enables VLM image captioning for embedded images
阅读文章/博客
# Standard article
jina read -u "https://blog.example.com/article"
# With specific format
jina read -u "https://example.com" --format text --output markdown
研究工作流
# 1. Search for topic
jina search -q "quantum computing 2025" --limit 10
# 2. Read specific results
jina read --file search_results.txt
批量处理
创建一个每行包含一个 URL 的文件:
cat > urls.txt << EOF
https://example.com/page1
https://example.com/page2
https://x.com/user/status/123
EOF
jina read --file urls.txt --output markdown
项目结构
cli/
├── main.go # Root command
├── read.go # read command
├── search.go # search command
├── config.go # config command
└── pkg/
├── api/client.go # Jina API HTTP client
├── config/ # Config file management
└── output/ # JSON/Markdown formatter
实现说明
- 需要 Go 1.24+
- 零依赖,Cobra 除外
- 单个二进制文件分发
- 配置以简单的
key=value格式存储(不依赖 YAML 库)
API 详情:参见 cli/pkg/api/client.go
评论
支持 Markdown