跳到正文
DEV Community· agebreakco-prog·· 1 小時前AI 評分56

如何只用普通 HTTP 標頭、HTML 和指令碼指紋識別網站技術組合,無需無頭瀏覽器

Detecting a website's tech stack from plain HTTP (headers, HTML and script fingerprints), no headless browser

AI 導讀

作者提供約 110 行、無需安裝額外套件的 Node 20+ 腳本,透過單次普通 GET 請求中的回應標頭、meta 標籤、HTML、script URL 和 Cookie 名稱識別網站技術組合,毋須使用無頭瀏覽器。

正文

AI disclosure: I wrote this article with AI assistance (Claude). The code is a trimmed-down version of a detector we maintain, and all the output below comes from running the script on 2026-11-23. We reviewed and tested everything.

"What is this site built with?" comes up all the time: qualifying sales leads ("show me Shopify stores using Klaviyo"), sizing a migration, checking what a competitor runs, or just auditing your own domains. Browser extensions like Wappalyzer answer it one site at a time. If you have a list of 500 domains, you want a script.

The good news is that you don't need a headless browser for most of it. A single plain GET request gives you three strong sources of evidence:

  1. Response headers: server, x-powered-by, CDN request IDs (cf-ray, x-vercel-id, x-nf-request-id), and cookie names in set-cookie.
  2. Meta tags: many generators announce themselves, for example <meta name="generator" content="WordPress 6.x">.
  3. The raw HTML and <script src> URLs: cdn.shopify.com, /_next/static/, wp-content/, googletagmanager.com/gtm.js and so on.

This post builds a dependency-free Node script (Node 20+, about 110 lines) that matches those against a small signature table, runs it on 11 public sites, and then goes through where it's wrong.

The idea: a signature table

Each technology is one object. A signature can match on any combination of HTML, script URLs, meta tags, headers and cookie names. An optional capture group gives you a version.

{ name: 'WordPress', category: 'CMS',
  html: /wp-content\/|wp-includes\//i,
  meta: { generator: /WordPress\s*([\d.]+)?/i } },

{ name: 'Cloudflare', category: 'CDN',
  header: { server: /cloudflare/i, 'cf-ray': /./ } },

{ name: 'Django', category: 'Web framework',
  cookie: /^(csrftoken|django_language)$/ },

Here's the part of the table the script below ships with, grouped by where the evidence comes from:

Evidence source Example signals Technologies
Header server: cloudflare, cf-ray Cloudflare
Header server: Vercel, x-vercel-id Vercel
Header server: Netlify, x-nf-request-id Netlify
Header x-served-by: cache-... Fastly
Header x-powered-by: Express / PHP/8.x Express, PHP
Meta generator WordPress 6.x, Hugo 0.x, Ghost 5.x, Docusaurus v3, VitePress v1 CMS and static site generators
HTML cdn.shopify.com Shopify
HTML /_next/static, __NEXT_DATA__ Next.js
HTML /_nuxt/, __NUXT__ Nuxt
HTML ng-version="17.0.0" Angular (with version)
Script src googletagmanager.com/gtag/js Google Analytics
Script src jquery-3.5.1.min.js jQuery (with version)
Cookie name _shopify_y, PHPSESSID, csrftoken Shopify, PHP, Django

Headers, meta tags and cookies are deliberate signals sent by the server or the generator, so they count double. A substring in the HTML is weaker, because it can appear in a blog post about the technology. The script turns that into a simple high / medium confidence.

The full script

Save this as detect.mjs. No npm install; it uses the built-in fetch.

// detect.mjs - tech stack detection over plain HTTP. Node 20+, no dependencies.
// Usage: node detect.mjs wordpress.org allbirds.com ...

const SIGNATURES = [
  // CMS / site builders
  { name: 'WordPress', category: 'CMS', html: /wp-content\/|wp-includes\//i, meta: { generator: /WordPress\s*([\d.]+)?/i } },
  { name: 'Drupal', category: 'CMS', header: { 'x-generator': /Drupal\s*([\d.]+)?/i, 'x-drupal-cache': /./ } },
  { name: 'Ghost', category: 'CMS', meta: { generator: /Ghost\s*([\d.]+)?/i } },
  { name: 'Webflow', category: 'Website builder', html: /data-wf-site/i, meta: { generator: /Webflow/i } },
  { name: 'Squarespace', category: 'Website builder', html: /static1?\.squarespace\.com/i },
  { name: 'Wix', category: 'Website builder', header: { 'x-wix-request-id': /./ }, html: /static\.wixstatic\.com/i },
  { name: 'Hugo', category: 'Static site generator', meta: { generator: /Hugo\s*([\d.]+)?/i } },
  { name: 'VitePress', category: 'Static site generator', meta: { generator: /VitePress\s*v?([\d.]+)?/i } },
  { name: 'Docusaurus', category: 'Static site generator', meta: { generator: /Docusaurus\s*v?([\d.]+)?/i } },
  // Ecommerce
  { name: 'Shopify', category: 'Ecommerce', html: /cdn\.shopify\.com/i, header: { 'x-shopid': /./ }, cookie: /^_shopify_/ },
  { name: 'WooCommerce', category: 'Ecommerce', html: /plugins\/woocommerce\//i },
  // JS frameworks
  { name: 'Next.js', category: 'JS framework', html: /__NEXT_DATA__|\/_next\/static/i, header: { 'x-powered-by': /Next\.js\s*([\d.]+)?/i } },
  { name: 'Nuxt', category: 'JS framework', html: /__NUXT__|\/_nuxt\//i },
  { name: 'Angular', category: 'JS framework', html: /ng-version="([\d.]+)"/i },
  { name: 'Astro', category: 'JS framework', html: /astro-island|data-astro-cid/i, meta: { generator: /Astro\s*v?([\d.]+)?/i } },
  { name: 'jQuery', category: 'JS library', script: /jquery[.-]?([\d.]+)?(\.min)?\.js/i },
  // Analytics / marketing
  { name: 'Google Tag Manager', category: 'Tag manager', html: /googletagmanager\.com\/gtm\.js|GTM-[A-Z0-9]{4,}/ },
  { name: 'Google Analytics', category: 'Analytics', script: /googletagmanager\.com\/gtag\/js/i },
  { name: 'Meta Pixel', category: 'Advertising', html: /connect\.facebook\.net\/[^"']*fbevents\.js|fbq\('init'/i },
  { name: 'Hotjar', category: 'Analytics', html: /static\.hotjar\.com/i },
  { name: 'Plausible', category: 'Analytics', script: /plausible\.io\/js/i },
  { name: 'OneTrust', category: 'Cookie consent', html: /cdn\.cookielaw\.org/i },
  { name: 'Stripe', category: 'Payments', html: /js\.stripe\.com/i },
  { name: 'Klaviyo', category: 'Email marketing', html: /static\.klaviyo\.com/i },
  // Infrastructure (headers)
  { name: 'Cloudflare', category: 'CDN', header: { server: /cloudflare/i, 'cf-ray': /./ } },
  { name: 'Fastly', category: 'CDN', header: { 'x-served-by': /cache-/i } },
  { name: 'Amazon CloudFront', category: 'CDN', header: { via: /CloudFront/i, 'x-amz-cf-id': /./ } },
  { name: 'Akamai', category: 'CDN', header: { server: /AkamaiGHost/i } },
  { name: 'Vercel', category: 'Hosting', header: { server: /Vercel/i, 'x-vercel-id': /./ } },
  { name: 'Netlify', category: 'Hosting', header: { server: /Netlify/i, 'x-nf-request-id': /./ } },
  { name: 'GitHub Pages', category: 'Hosting', header: { server: /^GitHub\.com$/ } }, // case-sensitive on purpose, see below
  { name: 'Nginx', category: 'Web server', header: { server: /nginx\/?([\d.]+)?/i } },
  { name: 'Apache', category: 'Web server', header: { server: /Apache\/?([\d.]+)?/i } },
  { name: 'PHP', category: 'Language', header: { 'x-powered-by': /PHP\/?([\d.]+)?/i }, cookie: /^PHPSESSID$/ },
  { name: 'Express', category: 'Web framework', header: { 'x-powered-by': /Express/i } },
  { name: 'Django', category: 'Web framework', cookie: /^(csrftoken|django_language)$/ },
  { name: 'Ruby on Rails', category: 'Web framework', html: /csrf-param" content="authenticity_token/i },
];

async function fetchPage(url, timeoutMs = 15000) {
  const ctrl = new AbortController();
  const timer = setTimeout(() => ctrl.abort(), timeoutMs);
  try {
    const res = await fetch(url, {
      redirect: 'follow',
      signal: ctrl.signal,
      headers: { 'user-agent': 'Mozilla/5.0 (compatible; StackSniffer/1.0)', accept: 'text/html,*/*;q=0.8', 'accept-language': 'en-US,en;q=0.8' },
    });
    const html = (await res.text()).slice(0, 3_000_000); // cap what we scan
    return { status: res.status, finalUrl: res.url, headers: res.headers, html };
  } finally {
    clearTimeout(timer);
  }
}

// Pull out the parts we match against. Regex is fine here: we only need
// attribute values, not a correct DOM.
function extract(html, headers) {
  const scripts = [...html.matchAll(/<script\b[^>]*\bsrc=["']([^"']+)["']/gi)].map((m) => m[1]);
  const metas = {};
  for (const m of html.matchAll(/<meta\b[^>]*>/gi)) {
    const tag = m[0];
    const name = tag.match(/\b(?:name|property)=["']([^"']+)["']/i)?.[1]?.toLowerCase();
    const content = tag.match(/\bcontent=["']([^"']*)["']/i)?.[1];
    if (name && content != null && !(name in metas)) metas[name] = content;
  }
  const cookies = headers.getSetCookie().map((c) => c.split('=')[0].trim());
  return { scripts, metas, cookies };
}

function detect({ html, headers, scripts, metas, cookies }) {
  const found = new Map();
  const hit = (sig, kind, evidence, m) => {
    const t = found.get(sig.name) ?? { name: sig.name, category: sig.category, version: null, score: 0, evidence: [] };
    t.score += kind === 'html' || kind === 'script' ? 1 : 2; // headers/meta/cookies are stronger signals
    if (t.evidence.length < 2) t.evidence.push(`${kind}: ${String(evidence).slice(0, 80)}`);
    if (!t.version && m?.[1] && /^\d+(\.\d+)*$/.test(m[1])) t.version = m[1];
    found.set(sig.name, t);
  };
  for (const sig of SIGNATURES) {
    if (sig.html) { const m = html.match(sig.html); if (m) hit(sig, 'html', m[0], m); }
    if (sig.script) for (const s of scripts) { const m = s.match(sig.script); if (m) { hit(sig, 'script', s, m); break; } }
    if (sig.meta) for (const [k, re] of Object.entries(sig.meta)) { const v = metas[k]; const m = v?.match(re); if (m) hit(sig, 'meta', `${k}=${v}`, m); }
    if (sig.header) for (const [k, re] of Object.entries(sig.header)) { const v = headers.get(k); const m = v?.match(re); if (m) hit(sig, 'header', `${k}: ${v}`, m); }
    if (sig.cookie) for (const c of cookies) if (sig.cookie.test(c)) { hit(sig, 'cookie', c); break; }
  }
  return [...found.values()].map(({ score, ...t }) => ({ ...t, confidence: score >= 2 ? 'high' : 'medium' }));
}

for (const arg of process.argv.slice(2)) {
  const url = /^https?:\/\//.test(arg) ? arg : `https://${arg}`;
  try {
    const page = await fetchPage(url);
    const techs = detect({ ...page, ...extract(page.html, page.headers) });
    console.log(`\n${arg} -> ${page.finalUrl} (${page.status}, ${Math.round(page.html.length / 1024)} KB)`);
    for (const t of techs) {
      console.log(`  ${t.category.padEnd(22)} ${(t.name + (t.version ? ' ' + t.version : '')).padEnd(22)} ${t.confidence.padEnd(6)} ${t.evidence[0]}`);
    }
    if (!techs.length) console.log('  (nothing detected)');
  } catch (err) {
    console.log(`\n${arg} -> ERROR ${err.name === 'AbortError' ? 'timeout' : err.cause?.code || err.message}`);
  }
}

Run it with any list of domains:

node detect.mjs wordpress.org allbirds.com nextjs.org

A few details are worth pointing out:

  • headers.getSetCookie() (Node 19.7+) returns each Set-Cookie header separately. headers.get('set-cookie') joins them with commas, and that breaks on cookie dates (Expires=Wed, 21 Oct...). Only the cookie names are kept, because the values are noise.
  • Regex instead of a DOM parser. The script only needs attribute values (src, name, content), so a couple of regexes over the raw HTML are enough and keep it dependency-free. If you add signatures that depend on structure, switch to cheerio.
  • Evidence is kept. Every hit records why it matched. When someone asks "are you sure they're on Shopify?", you can show them html: cdn.shopify.com instead of shrugging.
  • The accept-language header matters. Without it, stripe.com redirected me to a Spanish-language page based on geolocation. With it, I got /en-es. Either way, the stack is the same, but your evidence strings will differ by region.

Real output from 11 sites

I ran it on 2026-11-23 from a laptop in Europe. The whole run took 9.4 seconds, sequentially, one request per site:

node detect.mjs wordpress.org allbirds.com nextjs.org vuejs.org gohugo.io ghost.org \
  docusaurus.io github.com pages.github.com stripe.com app.netlify.com
wordpress.org -> https://wordpress.org/ (200, 174 KB)
  CMS                    WordPress 7.2          high   html: wp-content/
  Tag manager            Google Tag Manager     medium html: googletagmanager.com/gtm.js
  Web server             Nginx                  high   header: server: nginx

allbirds.com -> https://www.allbirds.com/ (200, 856 KB)
  Ecommerce              Shopify                high   html: cdn.shopify.com
  Tag manager            Google Tag Manager     medium html: googletagmanager.com/gtm.js
  CDN                    Cloudflare             high   header: server: cloudflare

nextjs.org -> https://nextjs.org/ (200, 260 KB)
  JS framework           Next.js                medium html: /_next/static
  Hosting                Vercel                 high   header: server: Vercel

vuejs.org -> https://vuejs.org/ (200, 82 KB)
  Static site generator  VitePress 2.0.0        high   meta: generator=VitePress v2.0.0-alpha.17
  Hosting                Netlify                high   header: server: Netlify

gohugo.io -> https://gohugo.io/ (200, 89 KB)
  Analytics              Google Analytics       medium script: https://www.googletagmanager.com/gtag/js?id=G-MBZGKNMDWC
  Hosting                Netlify                high   header: server: Netlify

ghost.org -> https://ghost.org/ (200, 120 KB)
  Static site generator  Hugo 0.119.0           high   meta: generator=Hugo 0.119.0
  Hosting                Netlify                high   header: server: Netlify

docusaurus.io -> https://docusaurus.io/ (200, 37 KB)
  Static site generator  Docusaurus 4.0.0       high   meta: generator=Docusaurus v4.0.0
  Analytics              Google Analytics       medium script: https://www.googletagmanager.com/gtag/js?id=G-E5CR2Q1NRE
  CDN                    Cloudflare             high   header: server: cloudflare
  Hosting                Netlify                high   header: x-nf-request-id: 01M83PBJ4F26JM1S3XQ73X2ES8

github.com -> https://github.com/ (200, 525 KB)
  (nothing detected)

pages.github.com -> https://pages.github.com/ (200, 14 KB)
  JS library             jQuery                 medium script: /js/jquery.js
  CDN                    Fastly                 high   header: x-served-by: cache-mad2200109-MAD
  Hosting                GitHub Pages           high   header: server: GitHub.com

stripe.com -> https://stripe.com/en-es (200, 733 KB)
  JS framework           Next.js                medium html: /_next/static
  Web server             Nginx                  high   header: server: nginx

app.netlify.com -> https://app.netlify.com/ (200, 18 KB)
  Hosting                Netlify                high   header: server: Netlify

Some of this is exactly what you'd expect: WordPress on wordpress.org (with the version from the generator tag), Shopify behind Cloudflare on Allbirds, Next.js on Vercel for nextjs.org, and VitePress on Netlify for vuejs.org.

Some of it is more interesting:

  • ghost.org's homepage is not Ghost. It's Hugo 0.119.0 on Netlify. When I first tried blog.ghost.org, it redirected to ghost.org/resources/, and that page reported Ghost 6.79 with Fastly in front. Companies often run their marketing site, blog and docs on different stacks, so the URL you test matters as much as the domain.
  • docusaurus.io shows both Cloudflare and Netlify. That's not a contradiction: Cloudflare sits in front as the CDN, and Netlify is the origin (it still leaks its x-nf-request-id header). Layered infrastructure is common, so don't assume one CDN per site.
  • gohugo.io doesn't say it's Hugo. Hugo only adds the generator tag if the theme includes {{ hugo.Generator }}, and this theme doesn't. The site is Hugo, but there's no evidence for it in the response.
  • github.com detects nothing. More on that below.

Where it gets things wrong

False positives from loose patterns

My first version had GitHub Pages: { server: /GitHub\.com/i }, and it told me that github.com is hosted on GitHub Pages. It isn't. github.com sends server: github.com (lowercase), while Pages sites send server: GitHub.com. Making the regex case-sensitive and anchored (/^GitHub\.com$/) fixed it, and pages.github.com still matches.

HTML substring signatures have the same problem on a bigger scale. A blog post that mentions wp-content/ in a code sample will "detect" WordPress. Some ways to reduce this:

  • Prefer headers, meta tags and cookies, which is what the confidence score does.
  • Match HTML signatures against src/href attribute values rather than the whole document when you can.
  • Require two independent signals before you report something as certain.

CDNs and big sites hide the origin

When a site is behind Cloudflare, Akamai or Fastly, the server header usually names the CDN, not nginx or Apache behind it. Large sites (github.com here) also deliberately strip x-powered-by, generator tags and framework markers. GitHub is famously a Rails app, but nothing in its homepage response says so in a way this table catches. "Nothing detected" means "no evidence", not "no technology".

JavaScript-rendered sites

app.netlify.com returned 18 KB of HTML and only the hosting header matched. It's a client-side app: the framework, analytics and everything else load after JavaScript runs. Plain HTTP sees the shell. The same goes for tools that are injected by a tag manager at runtime. You'll see Google Tag Manager, but not the ten tags it loads. If you need those, you need a real browser, and you pay for it in time and memory.

One page, one moment

You're looking at one response for one URL. Pages behind a login, checkout flows, A/B test variants, geo-specific versions (see the Stripe redirect) and cookie-consent walls can all change what you see. Bot protection may return a challenge page instead of the site. Don't try to get around that; record it as "blocked".

Coverage is the whole game

The detection logic is 20 lines. The value is in the signature table. Mine started without VitePress, and vuejs.org came back with only "Netlify" until I added one line. Open-source fingerprint sets (the Wappalyzer-derived ones on GitHub) have thousands of entries if you need breadth. Check their licenses before you use them commercially.

Scaling it up

For a few dozen domains, the script as-is is fine. For thousands, add:

  • Concurrency with a limit (5 to 10 parallel requests) and a per-host delay.
  • Retries with backoff on 429 and 5xx, honoring Retry-After.
  • A body size cap. Some homepages are several MB; the script above stops scanning after 3 MB of text.
  • Structured output (JSON or CSV, one row per site, with a byCategory map) so you can filter for "Shopify AND Klaviyo".

If you'd rather not maintain the signature table

We run the bigger version of this (160+ signatures in 40+ categories, with evidence and confidence for each detection, concurrency and retries) as an Apify actor: Website Tech Stack Detector. Full disclosure: it's ours, and it's pay per use, about $2 per 1,000 sites analysed, and failed sites aren't charged. It has the same limits described above: one HTTP request per URL and no JavaScript rendering. If you're also auditing the same list for titles, meta descriptions and Open Graph tags, there's a sibling actor for that: SEO Meta Audit.

For a handful of sites, though, the script above is all you need. Copy it, add the signatures you care about, and keep the evidence.

來源:DEV Community · dev.to