使用场景
SEO 分析
分析页面标题、描述和关键词以进行优化
社交媒体预览数据
获取 OpenGraph 和 Twitter Card 数据,用于丰富的社交预览
内容分类
使用元数据对网页内容进行分类和整理
生成链接预览
用标题、图片和描述构建丰富的链接预览
Endpoint
POST
/api/v1/tools/extract_metadataAuth Required
Free 计划 2 req/s
1 credit
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | Required | - | 要从中提取元数据的 URL Example: https://example.com/article |
请求示例
cURL
terminalBash
curl -X POST https://crawlforge.dev/api/v1/tools/extract_metadata \
-H "X-API-Key: cf_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/article"}'TypeScript
extractMetadata.tsTypescript
const response = await fetch('https://crawlforge.dev/api/v1/tools/extract_metadata', {
method: 'POST',
headers: {
'X-API-Key': process.env.CRAWLFORGE_API_KEY!,
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://example.com/article'
}),
});
const data = await response.json();
if (data.success) {
const { title, description, og, twitter } = data.data;
console.log('Title:', title);
console.log('Description:', description);
console.log('OG Image:', og.image);
console.log('Twitter Card:', twitter.card);
}响应示例
200 OK195ms
{ "success": true, "data": { "url": "https://example.com/article", "title": "Example Article - Best Practices Guide", "description": "Learn the best practices for web development in 2024", "keywords": "web development, best practices, tutorial", "language": "en", "canonical": "https://example.com/article", "og": { "title": "Example Article - Best Practices Guide", "description": "Learn the best practices for web development", "image": "https://example.com/og-image.jpg", "url": "https://example.com/article", "type": "article", "site_name": "Example Site" }, "twitter": { "images": [ "/api/og" ], "card": "summary_large_image", "title": "Example Article - Best Practices Guide", "description": "Learn the best practices for web development", "image": "https://example.com/twitter-image.jpg", "site": "@examplesite" } }, "credits_used": 1, "credits_remaining": 999, "processing_time": 195}Field Descriptions
data.title来自 <title> 标签的页面标题data.descriptionmeta 描述data.og用于社交媒体分享的 OpenGraph 标签data.twitter用于 Twitter 预览的 Twitter Card 标签data.canonical页面的规范 URL相关工具
准备好提取元数据了吗?免费注册,获取 1,000 credits。