登录

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' -G
from 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
string
最终 URL。
title
string
页面 title 标签。
meta_description
string | null
Meta description。
canonical_url
string | null
规范链接。
language
string | null
检测到的语言。
headings
object
h1/h2/h3 标题文本数组。
links
array
出站链接,包含 href、text、rel。
images
array
图片 URL 及其 alt 文本。
main_content
string
提取的可读正文文本。

响应示例

{
  "url": "https://stackoverflow.com/",
  "title": "Stack Overflow - Where Developers Learn...",
  "language": "en",
  "headings": {
    "h1": ["Where developers grow together"],
    "h2": ["Hot Network Questions"]
  }
}