Scrapers built on CSS selectors break whenever a site changes its markup, and you need a new one for every site. An LLM with a JSON schema doesn't care about markup: give it the page's content and the fields you want, and it returns them, on any site, in the same shape. What it needs is clean input: the page after JavaScript ran, without scripts, styles, cookie banners and navigation. That's the part shotkit does.
Step 1: get the page as Markdown
Render the page in Chrome and get only its content back. selector keeps the part you care about, which also cuts the tokens you pay the LLM for:
curl -X POST "https://shotkit.net/api/take" \
-H "X-Access-Key: YOUR_ACCESS_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/pricing","format":"markdown","selector":"main","block_cookie_banners":true,"block_chats":true}' \
--fail-with-body -o shot.mdSingle-page apps, prices loaded by JavaScript and content behind a "Show more" button come through; use click or wait_for_selector for content that appears late. See website to Markdown for the details.
Step 2: extract fields with a JSON schema
Send the Markdown to a model that supports structured output, with the schema you want filled in. With OpenAI's Structured Outputs, the response always matches the schema:
import OpenAI from "openai";
const markdown = await fetch("https://shotkit.net/api/take", {
method: "POST",
headers: { "X-Access-Key": process.env.SHOTKIT_KEY, "Content-Type": "application/json" },
body: JSON.stringify({ url: "https://example.com/pricing", format: "markdown", selector: "main", block_cookie_banners: true }),
}).then((r) => r.text());
const schema = {
type: "object",
additionalProperties: false,
required: ["plans"],
properties: {
plans: {
type: "array",
items: {
type: "object",
additionalProperties: false,
required: ["name", "price_monthly", "currency", "features"],
properties: {
name: { type: "string" },
price_monthly: { type: ["number", "null"] },
currency: { type: ["string", "null"] },
features: { type: "array", items: { type: "string" } },
},
},
},
},
};
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{ role: "system", content: "Extract the pricing plans from the page. Use null for values that aren't on the page; never guess." },
{ role: "user", content: markdown },
],
response_format: { type: "json_schema", json_schema: { name: "pricing", strict: true, schema } },
});
const data = JSON.parse(completion.choices[0].message.content);
// { plans: [{ name: "Pro", price_monthly: 29, currency: "USD", features: ["10,000 screenshots", …] }, …] }Claude, Gemini and most open models also accept a JSON schema for their output; the Markdown input stays the same. Write the schema for the answer you want, not for the page: the same schema then works on every site.
Add the screenshot when layout matters
Some facts are visual: which plan is highlighted as recommended, whether a product shows as sold out, what a badge or icon means. Get the screenshot and the Markdown from one render, then send both to a vision model:
curl -X POST "https://shotkit.net/api/take" \
-H "X-Access-Key: YOUR_ACCESS_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/pricing","response_type":"json","format":"jpg","image_width":1024,"full_page":true,"metadata_content":true,"metadata_content_format":"markdown","block_cookie_banners":true}' \
--fail-with-body -o shot.jsonconst shot = await take(params); // the request above, as in step 2
const markdown = await fetch(shot.content.url).then((r) => r.text());
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{ role: "system", content: "Extract the pricing plans. The text is exact; use the image for layout and highlights." },
{ role: "user", content: [
{ type: "text", text: markdown },
{ type: "image_url", image_url: { url: shot.screenshot_url } },
] },
],
response_format: { type: "json_schema", json_schema: { name: "pricing", strict: true, schema } },
});The text gives exact words and numbers, which models misread less often than text in an image; the image adds what the text can't show. image_width keeps the screenshot small, which lowers the model's cost.
Quick answers without code
For a few fields where an exact schema isn't critical, the built-in vision call asks the question in the same request, with your OpenAI key. The answer is the model's text, so ask for JSON and parse it yourself:
curl -X POST "https://shotkit.net/api/take" \
-H "X-Access-Key: YOUR_ACCESS_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com","response_type":"json","block_cookie_banners":true,"openai_api_key":"sk-YOUR_OPENAI_KEY","vision_prompt":"Reply with JSON only: {\"company\": string, \"category\": string, \"has_free_plan\": boolean}","vision_max_tokens":120}' \
--fail-with-body -o shot.jsonSee AI website analysis for more examples.
Many pages at once
- Send each URL with
async=true, awebhook_urlandexternal_identifierset to your record ID, so the results come back to your server as they finish. See async renders and webhooks. - Run the extraction in the webhook handler and store the JSON with the record ID.
- Re-run on a schedule and compare the JSON, not the page, to see when a price or a field changed. See price monitoring.
Keep the data trustworthy
- Allow
nullin the schema and tell the model to use it. Without that option, models fill required fields with guesses. - Check values that matter in code: a price is positive, a URL is on the expected domain, a date is in the past.
- Use
fail_if_content_missingwith text that's always on the page, so a block page or an error page fails the render instead of producing empty data. - Keep the Markdown with the result, so you can see what the model was given when a value looks wrong.
Frequently asked questions
How do I extract structured data from a website?
Render the page to Markdown, then send the Markdown with a JSON schema to an LLM that supports structured output. The model returns JSON in the schema's shape, on any site, without writing selectors for each one.
Does it work on pages that need JavaScript?
Yes. Pages are rendered in Chrome before conversion, so content loaded by JavaScript is included. click, scripts and wait_for_selector handle content that only appears after an interaction or a delay.
Which model should I use?
A small model such as gpt-4o-mini handles most pages well and costs little per page. Use a larger model when the page is long, the fields need judgement, or you send the screenshot as well.
How much does one extraction cost?
One screenshot from your plan, plus the LLM tokens, which you pay to your model provider. A selector on the main content and a narrow screenshot cut the tokens the most.
Is my LLM key sent to shotkit?
Not with the two-step approach above: shotkit returns the Markdown and your code calls the model. With the built-in vision_prompt, the key is passed with the request and used for that call only; it isn't stored.