Generic Extractor
通用站点提取器 - 从任意网页中提取链接、图片、标题和主要内容。
API 使用
在 Crawling API 请求中添加 &scraper=generic-extractor。在 url 参数中对目标 URL 进行 URL 编码。
curl 'https://api.crawlbase.com/?token=YOUR_TOKEN' \
--data-urlencode 'url=https://stackoverflow.com/' \
--data-urlencode 'scraper=generic-extractor' -Gfrom crawlbase import CrawlingAPI
api = CrawlingAPI({'token': 'YOUR_TOKEN'})
res = api.get(
'https://stackoverflow.com/',
{'scraper': 'generic-extractor'}
)
import json
data = json.loads(res['body'])const { CrawlingAPI } = require('crawlbase');
const api = new CrawlingAPI({ token: 'YOUR_TOKEN' });
const res = await api.get(
'https://stackoverflow.com/',
{ scraper: 'generic-extractor' }
);
const data = JSON.parse(res.body);require 'crawlbase'
api = Crawlbase::API.new(token: 'YOUR_TOKEN')
res = api.get('https://stackoverflow.com/', scraper: 'generic-extractor')
data = JSON.parse(res.body)示例输入 URL
传入 url 参数的 URL(为便于阅读已进行 URL 解码):
https://stackoverflow.com/响应结构
JSON 响应体。当源页面缺少相应值时,字段类型可能为 null。
最终 URL。
页面 title 标签。
Meta description。
规范链接。
检测到的语言。
h1/h2/h3 标题文本数组。
出站链接,包含 href、text、rel。
图片 URL 及其 alt 文本。
提取的可读正文文本。
响应示例
{
"url": "https://stackoverflow.com/",
"title": "Stack Overflow - Where Developers Learn...",
"language": "en",
"headings": {
"h1": ["Where developers grow together"],
"h2": ["Hot Network Questions"]
}
}