crawlbaseDocs
Se connecter

Utilisation de l'API

Ajoutez &scraper=generic-extractor à une requête Crawling API. Encodez l'URL cible en URL-encoding dans le paramètre 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)

Exemple d'URL d'entrée

L'URL passée dans le paramètre url (décodée pour plus de lisibilité) :

https://stackoverflow.com/

Structure de la réponse

Corps de réponse JSON. Les types de champs peuvent être null lorsque la page source omet la valeur.

url
string
URL finale.
title
string
Balise title de la page.
meta_description
string | null
Meta description.
canonical_url
string | null
Lien canonique.
language
string | null
Langue détectée.
headings
object
Tableaux h1/h2/h3 du texte des titres.
links
array
Liens sortants avec href, text, rel.
images
array
URLs des images avec texte alt.
main_content
string
Texte lisible du corps extrait.

Exemple de réponse

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