MohammedAltounsi 的 AI-Website-Auditor:用 Claude 与 PageSpeed 生成网站健康评分
MohammedAltounsi/AI-Website-Auditor
开源项目 AI-Website-Auditor 输入 URL 即可返回网站 Health Score、Google PageSpeed Insights 的性能/无障碍/SEO/最佳实践四项评分、Claude 撰写的摘要和按严重程度排序的修复清单,支持导出 PDF 或 CSV。
Open the live demo · Run it locally · How it works
Paste a URL and the auditor returns a Health Score, a breakdown of performance, accessibility, SEO and best practices from Google PageSpeed Insights, a short Claude-written summary, and a severity-ranked list of fixes. You can export the report as PDF or CSV.
A real run
This is the live app auditing stripe.com. The four category scores come straight from PageSpeed. The 73 in the middle is their average, rounded.
The core design decision
The model never produces the Health Score. The code takes the four real
PageSpeed scores and runs Math.round() on their average, so the same site
gets the same score on every audit. Claude writes the summary and the fix
list and nothing else.
The rule this project demonstrates: the model explains, the code decides anything that has to stay consistent between runs.
How an audit runs
File-by-file walkthrough
lib/scrape.tsfetches the target page and extracts on-page SEO signals withcheerio: title, meta description, H1 count, alt-text coverage, canonical tag, viewport meta and word count.lib/pagespeed.tscalls the PageSpeed Insights API (mobile strategy) for the four category scores, retries transient 5xx errors up to three times, and computes the Health Score as their average.lib/analyze.tssends the scrape and PageSpeed data to Claude with forced tool-use (tool_choice: { type: 'tool' }). The response is always a structured object that matches thesubmit_audit_reportschema, never free text to parse.app/api/audit/route.tsruns the pipeline and returns one JSON report.app/page.tsx+app/components/*render the URL form, the animated Health Score gauge, the category breakdown, the severity-badged fix list, and PDF (browser print) and CSV export.
Safe to point at any URL
The auditor fetches whatever public URL a visitor types, so lib/scrape.ts
treats that input as hostile:
- SSRF protection. It resolves DNS first, blocks private, loopback,
link-local and IPv4-mapped IPv6 ranges, then pins the connection to the
checked IP. A public hostname that resolves to
169.254.169.254gets rejected. - Redirects. It follows up to 5 redirects by hand and re-checks every hop, so a public URL cannot redirect into an internal address.
- Limits. Each fetch times out after 15 seconds and stops reading at 5 MB.
- CSV export. It escapes cells that start with
=,+,-or@to prevent formula injection in spreadsheet apps.
Run it locally
You need Node.js, an Anthropic API key and a Google Cloud key with the PageSpeed Insights API enabled.
npm install
cp .env.local.example .env.local
# set ANTHROPIC_API_KEY and PAGESPEED_API_KEY in .env.local
npm run devRun the test suite:
npm testStack
Next.js 16 (App Router), TypeScript, Tailwind CSS 4, Google PageSpeed
Insights API, Anthropic API (claude-sonnet-5 with forced tool-use),
Vitest and Testing Library.
Roadmap
- Persist past audits (Postgres or Supabase) so a user can reopen a report by link.
- Competitor mode: audit two URLs and diff the fixes.
- AI-crawler (GEO) visibility check: can ChatGPT, Perplexity or Gemini find and cite the page.
- Weighted Health Score once real usage shows which category should count more.
- Mobile and desktop PageSpeed toggle instead of mobile only.
- Per-IP rate limiting (Vercel KV) once the tool sees real traffic.
Built and designed by Mohammed Altounsi · LinkedIn
来源:GitHub · github.com
