Çfarë marrin në fakt crawlerat e AI nga faqja jote? Një skript me 66 rreshta

Publikuar

Përgjigje e shkurtër

Kërko faqen tënde si shfletues dhe si secili crawler i AI, pastaj krahaso. Një 403, një 429 ose një faqe sfide vetëm për crawlerin, ose një 200 shumë më i vogël se faqja e shfletuesit, do të thotë se firewall-i e refuzon crawlerin edhe kur robots.txt e lejon. Një skript Node me 66 rreshta e bën këtë për shtatë crawlerë dhe e lexon robots.txt sipas rregullave të RFC 9309.

robots.txt i tregon një crawleri çfarë mund të marrë. Nuk thotë asgjë për atë që firewall-i ose CDN-ja në fakt kthen. Ky shkrim të jep një skript të shkurtër që i tregon të dyja krah për krah, që të shohësh ku nuk përputhen.

Në këtë faqe
  1. Pse robots.txt nuk tregon çfarë merr një crawler?
  2. Skripti
  3. Si e ekzekutoj?
  4. Si duket rezultati?
  5. Si e lexoj tabelën?
  6. Çfarë nuk mund të të tregojë skripti?
  7. Çfarë shohim në sajte reale?

Pse robots.txt nuk tregon çfarë merr një crawler?

robots.txt është një kërkesë. Çfarë dërgohet realisht e vendos një firewall, një CDN ose një rregull mbrojtjeje nga botët, dhe ai mund t'i përgjigjet OAI-SearchBot ose PerplexityBot me një 403, një 429 ose një faqe "Just a moment...", ndërsa vizitat e tua me shfletues duken krejt normale.

Kontrolli është të kërkosh të njëjtën URL si shfletues dhe si crawler, e pastaj të krahasosh. Një 403, 429 ose 503 vetëm për crawlerin, një faqe me titull Just a moment..., ose një përgjigje 200 shumë më e vogël se ajo e shfletuesit, të gjitha tregojnë firewall-in.

Skripti

Ruaje si ai-crawler-view.mjs. Kërkon Node 18 ose më të ri dhe asnjë paketë. Lexon robots.txt një herë, merr faqen tënde si shfletues, pastaj si shtatë crawlerë të AI: OAI-SearchBot, ChatGPT-User, GPTBot, Claude-SearchBot, ClaudeBot, PerplexityBot dhe Perplexity-User.

#!/usr/bin/env node
// ai-crawler-view: what do AI crawlers get from YOUR site, compared with a browser?
// Usage: node ai-crawler-view.mjs https://your-site.com/page [--expect "a sentence from your page"]
// Node 18+, no dependencies. Run it against sites you own: it sends requests with crawler user agents.
const BROWSER = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36";
const BOTS = [ // [robots.txt token, user agent]; Anthropic prints no full strings, so Claude gets a token-based one
  ["OAI-SearchBot", "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; OAI-SearchBot/1.0; +https://openai.com/searchbot"],
  ["ChatGPT-User", "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; ChatGPT-User/1.0; +https://openai.com/bot"],
  ["GPTBot", "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; GPTBot/1.1; +https://openai.com/gptbot"],
  ["Claude-SearchBot", "Mozilla/5.0 (compatible; Claude-SearchBot/1.0)"],
  ["ClaudeBot", "Mozilla/5.0 (compatible; ClaudeBot/1.0)"],
  ["PerplexityBot", "Mozilla/5.0 (compatible; PerplexityBot/1.0; +https://perplexity.ai/perplexitybot)"],
  ["Perplexity-User", "Mozilla/5.0 (compatible; Perplexity-User/1.0; +https://perplexity.ai/perplexity-user)"],
];
const BLOCK = new Set([401, 403, 406, 429, 451, 503, 999]);
const CHALLENGE = /Just a moment\.\.\.|Attention Required! \| Cloudflare|\/cdn-cgi\/challenge-platform|_Incapsula_Resource|Access Denied/i;

const [url, ...rest] = process.argv.slice(2);
const expect = rest.includes("--expect") ? rest[rest.indexOf("--expect") + 1] : "";
if (!url) { console.error("usage: node ai-crawler-view.mjs https://site/page [--expect \"text\"]"); process.exit(2); }

async function get(u, ua) {
  try {
    const r = await fetch(u, { headers: { "user-agent": ua }, redirect: "follow", signal: AbortSignal.timeout(15000) });
    return { status: r.status, body: (await r.text()).slice(0, 500000) };
  } catch (e) { return { status: 0, body: "", error: e.cause?.code || e.name }; }
}

// robots.txt, RFC 9309 in short: the group naming the token wins, else "*"; longest match wins; Allow wins a tie.
function robotsVerdict(txt, token, path) {
  const groups = []; let cur = null;
  for (const raw of txt.split(/\r?\n/)) {
    const m = raw.replace(/#.*/, "").match(/^\s*([A-Za-z-]+)\s*:\s*(.*?)\s*$/); if (!m) continue;
    const [k, v] = [m[1].toLowerCase(), m[2]];
    if (k === "user-agent") { if (!cur || cur.rules.length) groups.push(cur = { agents: [], rules: [] }); cur.agents.push(v.toLowerCase()); }
    else if (cur && (k === "allow" || k === "disallow") && v) cur.rules.push([k, v]);
  }
  const g = groups.find(x => x.agents.includes(token.toLowerCase())) || groups.find(x => x.agents.includes("*"));
  if (!g) return "no rule";
  let best = null;
  for (const [k, p] of g.rules) {
    const re = new RegExp("^" + p.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\\\$$/, "$"));
    if (re.test(path) && (!best || p.length > best[1].length || (p.length === best[1].length && k === "allow"))) best = [k, p];
  }
  return best ? `${best[0]}: ${best[1]}` : "no rule";
}

const target = new URL(url);
const robots = await get(new URL("/robots.txt", target).href, BROWSER);
const robotsOk = robots.status >= 200 && robots.status < 300 && !/<html/i.test(robots.body);
const control = await get(url, BROWSER);
const cLen = control.body.length;
console.log(`control (browser): HTTP ${control.status}, ${cLen} bytes${expect ? `, expected text ${control.body.includes(expect) ? "found" : "MISSING"}` : ""}`);
if (control.status === 0 || BLOCK.has(control.status)) console.log("  the browser request itself failed or was refused: results below are not meaningful");
console.log(`robots.txt: ${robots.status >= 500 ? "server error (RFC 9309: crawlers must assume everything is disallowed)" : robotsOk ? "read" : "none or not valid"}\n`);
console.log("crawler           robots.txt          HTTP  bytes   verdict");
for (const [token, ua] of BOTS) {
  const r = await get(url, ua);
  const rule = robotsOk ? robotsVerdict(robots.body, token, target.pathname + target.search) : "no rule";
  const challenge = CHALLENGE.test(r.body.slice(0, 20000)) && r.body.length < 20000;
  const verdict = BLOCK.has(r.status) || challenge ? "BLOCKED by the server"
    : r.status >= 400 || r.status === 0 ? `error ${r.status || r.error}`
    : r.body.length < cLen * 0.5 ? "THIN: much smaller than the browser's page"
    : expect && !r.body.includes(expect) ? "text MISSING from the HTML" : "ok";
  console.log(`${token.padEnd(17)} ${rule.padEnd(19)} ${String(r.status).padEnd(5)} ${String(r.body.length).padEnd(7)} ${verdict}${rule.startsWith("disallow") ? "  (robots.txt asks it to stay away)" : ""}`);
}

Anthropic nuk publikon vargje të plota user agent, ndaj dy rreshtat e Claude përdorin vetëm tokenin e crawlerit. Një firewall që krahason tokenin reagon njësoj.

Si e ekzekutoj?

Ekzekutoje mbi një faqe të sajtit tënd. Flamuri opsional --expect kontrollon nëse një fjali nga përmbajtja kryesore gjendet në HTML-në e papërpunuar që merr secili crawler. Nëse mungon, skriptet e shtojnë tekstin pas ngarkimit, dhe shumë crawlerë nuk e shohin.

node ai-crawler-view.mjs https://your-site.com/pricing/ --expect "a sentence from your page"

Ekzekutoje vetëm në sajte që i ke ti ose që ke leje t'i testosh. Dërgon nëntë kërkesa: robots.txt, shfletuesin dhe një për secilin crawler.

Si duket rezultati?

Ky është rezultati ndaj një serveri lokal testimi qëllimisht armiqësor, që sfidon OAI-SearchBot, kufizon shpejtësinë e ClaudeBot, i shërben PerplexityBot një guaskë boshe dhe e ndalon GPTBot në robots.txt:

control (browser): HTTP 200, 2618 bytes, expected text found
robots.txt: read

crawler           robots.txt          HTTP  bytes   verdict
OAI-SearchBot     allow: /            403   31      BLOCKED by the server
ChatGPT-User      allow: /            200   2618    ok
GPTBot            disallow: /         200   2618    ok  (robots.txt asks it to stay away)
Claude-SearchBot  allow: /            200   2618    ok
ClaudeBot         allow: /            429   9       BLOCKED by the server
PerplexityBot     allow: /            200   36      THIN: much smaller than the browser's page
Perplexity-User   allow: /            200   2618    ok

Në aiseewhy.com çdo crawler merr faqen e plotë, me të njëjtin status dhe madhësi si shfletuesi.

Si e lexoj tabelën?

Çfarë nuk mund të të tregojë skripti?

Çfarë shohim në sajte reale?

AISeeWhy kryen këtë lloj kontrolli për 14 crawlerë. Nga 165 sajte biznesi në SHBA, Britani dhe Francë që mundëm t'i testonim, 38% (63 sajte) refuzuan të paktën një crawler të AI në server, ndërsa një shfletues nga e njëjta adresë e mori faqen. Secili prej atyre sajteve refuzoi të paktën një bot trajnimi ose zhvjelljeje, dhe 10% (16 sajte) refuzuan edhe të paktën një crawler kërkimi të AI, si PerplexityBot (11 sajte) ose OAI-SearchBot (5).

Sajtet nuk janë mostër e rastësishme, dhe 53 të tjerë nuk u testuan dot sepse edhe një kërkesë e thjeshtë shfletuesi u refuzua ose mbeti pa përgjigje. Trajtoje si një model që ia vlen ta kontrollosh në sajtin tënd, jo si regjistrim të plotë.

Mjete falas

Hapat e radhës

Zvarritësit në këtë artikull

Pyetje të shpeshta

A është e sigurt ta ekzekutoj kundër çdo sajti?

Ekzekutoje vetëm kundër sajteve që i ke ti ose që ke leje t'i testosh. Dërgon kërkesa me user agent crawlerësh, që disa mbrojtje nga botët i trajtojnë si armiqësore.

Pse GPTBot shfaqet ok kur robots.txt e ndalon?

robots.txt është kërkesë, jo çelës. Serveri i përgjigjet kujtdo që e shpërfill, ndaj kolona HTTP thotë ok. Rregulli pranë tij tregon çfarë respekton një crawler i sjellshëm.

A ekzekuton skripti JavaScript?

Jo, qëllimisht. Tregon HTML-në që merr një crawler që nuk i renderon faqet. Flamuri --expect të tregon nëse teksti yt kryesor gjendet tashmë në atë HTML.

A do të thotë një rezultat i pastër që ChatGPT do ta citojë faqen time?

Jo. Qasja është e nevojshme, por jo e mjaftueshme. Për të parë nëse një asistent e emërton sajtin tënd, pyete me pyetjet që bëjnë blerësit e tu dhe shëno cilat sajte citon.

Burimet

Më shumë artikuj