PlaybooksCrawl Any Website
Crawl a webpage
Fetch the HTML of a page with the crawler.
Call GET /v2/website/crawler with the query parameter set to the target URL. A successful call answers 200, and its JSON body is a single string holding the page HTML, for example:
"<!doctype html><html lang=\"en\"><head><title>Example Domain</title>…</head><body><div><h1>Example Domain</h1>…</div></body></html>"Decode it with a JSON parser to get the HTML.
import os
import requests
API_KEY = os.environ["PILOTERR_API_KEY"]
response = requests.get(
"https://api.piloterr.com/v2/website/crawler",
headers={"x-api-key": API_KEY},
params={"query": "https://example.com"},
)
if response.status_code != 200:
raise SystemExit(f"Error {response.status_code}: {response.text}")
html = response.json() # the JSON body is a string holding the HTML
print(html[:500])