René's URL Explorer Experiment


Title: Run a Lighthouse audit in Python — working code

Open Graph Title: Run a Lighthouse audit in Python — working code

X Title: Run a Lighthouse audit in Python — working code

Description: Run Lighthouse from Python and print the four scores, LCP, CLS and TBT: sync, async with a webhook, and retries. Tested code.

Open Graph Description: Run Lighthouse from Python and print the four scores, LCP, CLS and TBT: sync, async with a webhook, and retries. Tested code.

X Description: Run Lighthouse from Python and print the four scores, LCP, CLS and TBT: sync, async with a webhook, and retries. Tested code.

Mail addresses
contact@urlpipe.dev

Opengraph URL: https://urlpipe.dev/code/python/lighthouse-audit

direct link

Domain: urlpipe.dev


Hey, it has json ld scripts:
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://urlpipe.dev/#organization","name":"URLpipe","url":"https://urlpipe.dev","logo":"https://urlpipe.dev/icon.png","sameAs":["https://github.com/URLpipe"],"founder":{"@type":"Person","name":"Roger Campos","url":"https://rogercampos.com"}},{"@type":"WebSite","@id":"https://urlpipe.dev/#website","url":"https://urlpipe.dev","name":"URLpipe","publisher":{"@id":"https://urlpipe.dev/#organization"}}]}
{"@context":"https://schema.org","@graph":[{"@type":"TechArticle","@id":"https://urlpipe.dev/code/python/lighthouse-audit#article","headline":"Run a Lighthouse audit in Python — working code","description":"Run Lighthouse from Python and print the four scores, LCP, CLS and TBT: sync, async with a webhook, and retries. Tested code.","url":"https://urlpipe.dev/code/python/lighthouse-audit","mainEntityOfPage":"https://urlpipe.dev/code/python/lighthouse-audit","datePublished":"2026-09-24","dateModified":"2026-09-24","author":{"@type":"Person","name":"Roger Campos","url":"https://rogercampos.com"},"publisher":{"@id":"https://urlpipe.dev/#organization"},"image":"https://urlpipe.dev/og-image.png"},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"Mobile or desktop — which device should I audit?","acceptedAnswer":{"@type":"Answer","text":"Mobile, unless you know your traffic is desktop. It emulates a 360×640 phone with a 4× slower CPU and a slow 4G network, which gives the lower, more telling scores. Pass device: \"desktop\" for a 1350×940 window with no throttling."}},{"@type":"Question","name":"Why isn't INP in the results?","acceptedAnswer":{"@type":"Answer","text":"INP is measured from real users interacting with the page, which a lab audit cannot do. Total Blocking Time is the lab metric that tracks it."}},{"@type":"Question","name":"Why use the async variant for Lighthouse?","acceptedAnswer":{"@type":"Answer","text":"An audit takes around 15 seconds, longer on a heavy page. Async hands you a token at once and delivers the report to your webhook, so nothing holds a connection open waiting."}},{"@type":"Question","name":"Do I need an SDK to call URLpipe from Python?","acceptedAnswer":{"@type":"Answer","text":"No SDK is needed: requests is the only dependency, because the API is one POST per job. If you'd rather use one, the official client installs with pip install urlpipe and adds retries that never bill twice, typed errors and webhook verification."}}]},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://urlpipe.dev/"},{"@type":"ListItem","position":2,"name":"Code recipes","item":"https://urlpipe.dev/code"},{"@type":"ListItem","position":3,"name":"Python","item":"https://urlpipe.dev/code/python"},{"@type":"ListItem","position":4,"name":"Run a Lighthouse audit in Python","item":"https://urlpipe.dev/code/python/lighthouse-audit"}]},{"@type":"HowTo","name":"Run a Lighthouse audit in Python","description":"To run a Lighthouse audit in Python, POST a URL and a device to https://urlpipe.dev/lighthouse and read the JSON with res.json(): four category scores from 0 to 1 and the lab metrics, LCP, CLS and TBT among them. An audit takes around 15 seconds, so the async variant with a webhook suits production. It costs 2 credits.","url":"https://urlpipe.dev/code/python/lighthouse-audit","tool":[{"@type":"HowToTool","name":"Python 3.9+"}],"step":[{"@type":"HowToStep","name":"Before you start","text":"One dependency, requests. Put your API key in the environment so it never lands in the file.","url":"https://urlpipe.dev/code/python/lighthouse-audit#setup"},{"@type":"HowToStep","name":"Print the four scores, LCP, CLS and TBT","text":""sync": True holds the connection open until the result is ready and answers with it. Pass timeout= every time: requests has no default, and a page that never finishes loading would otherwise hang your process. Scores arrive from 0 to 1 and any of them can be None when Lighthouse could not compute it, so the loop checks before multiplying.","url":"https://urlpipe.dev/code/python/lighthouse-audit#sync"},{"@type":"HowToStep","name":"The async variant: a token, a webhook and a poll","text":"Leave out sync and the answer is a token, straight away. for … else is the idiom for "ran out of attempts": the else runs only when the loop never hit break.","url":"https://urlpipe.dev/code/python/lighthouse-audit#async"},{"@type":"HowToStep","name":"Handle errors and retries","text":"raise_for_status() is fine for a script; a service wants to tell the failures apart. Check the status before calling res.json() — an error from a proxy in front of the API may not be JSON. sys.exit(message) prints to stderr and exits 1.","url":"https://urlpipe.dev/code/python/lighthouse-audit#errors"}]}]}

view-transitionsame-origin
csrf-paramauthenticity_token
csrf-tokenLUozZMyMzKotdSke_Z9AtIsmKpKmQQmKTfl17HYKBn-2dHKx9svqMb88N6wr2SJ0o5a9RzoDoFLeYbi7t8gLYQ
csp-nonce909a30294989ed5b7a13de9c48146fa0
og:typewebsite
og:site_nameURLpipe
og:localeen_US
og:imagehttps://urlpipe.dev/og-image.png
og:image:width1200
og:image:height630
og:image:altURLpipe — URL in. Clean data out.
twitter:cardsummary_large_image
twitter:imagehttps://urlpipe.dev/og-image.png
twitter:image:altURLpipe — URL in. Clean data out.
theme-color#3b82f6

Links:

Skip to main contenthttps://urlpipe.dev/code/python/lighthouse-audit#main
URLpipehttps://urlpipe.dev/
Web scraping APIhttps://urlpipe.dev/web-scraping-api
URL to Markdown APIhttps://urlpipe.dev/url-to-markdown-api
MCP serverhttps://urlpipe.dev/mcp-server
Screenshot APIhttps://urlpipe.dev/screenshot-api
Lighthouse APIhttps://urlpipe.dev/lighthouse-api
Metadata APIhttps://urlpipe.dev/metadata-api
Console APIhttps://urlpipe.dev/console-api
Rendered HTML APIhttps://urlpipe.dev/rendered-html-api
URL to PDF APIhttps://urlpipe.dev/url-to-pdf-api
Website technology lookup APIhttps://urlpipe.dev/website-technology-lookup-api
Structured data extraction APIhttps://urlpipe.dev/structured-data-extraction-api
Keyword extraction APIhttps://urlpipe.dev/keyword-extraction-api
URL summarization APIhttps://urlpipe.dev/url-summarization-api
Web access for AI agentshttps://urlpipe.dev/use-cases/ai-agents
Web pages into a RAG pipelinehttps://urlpipe.dev/use-cases/rag-ingestion
Link previews and unfurlshttps://urlpipe.dev/use-cases/link-previews
Monitoring client websiteshttps://urlpipe.dev/use-cases/client-site-monitoring
Monitoring pages for changeshttps://urlpipe.dev/use-cases/content-monitoring
Archiving pages as screenshotshttps://urlpipe.dev/use-cases/visual-archiving
URL features inside a multi-tenant apphttps://urlpipe.dev/use-cases/multi-tenant-apps
Free toolshttps://urlpipe.dev/tools
Docshttps://urlpipe.dev/docs
Pricinghttps://urlpipe.dev/pricing
Guideshttps://urlpipe.dev/guides
Code recipeshttps://urlpipe.dev/code
Glossaryhttps://urlpipe.dev/glossary
Researchhttps://urlpipe.dev/research
Comparehttps://urlpipe.dev/compare
Changeloghttps://urlpipe.dev/changelog
Engineering noteshttps://urlpipe.dev/notes
Sign inhttps://urlpipe.dev/auth/session/new
Start freehttps://urlpipe.dev/auth/sign-up/new
Web scraping APIhttps://urlpipe.dev/web-scraping-api
URL to Markdown APIhttps://urlpipe.dev/url-to-markdown-api
MCP serverhttps://urlpipe.dev/mcp-server
Screenshot APIhttps://urlpipe.dev/screenshot-api
Lighthouse APIhttps://urlpipe.dev/lighthouse-api
Metadata APIhttps://urlpipe.dev/metadata-api
Console APIhttps://urlpipe.dev/console-api
Rendered HTML APIhttps://urlpipe.dev/rendered-html-api
URL to PDF APIhttps://urlpipe.dev/url-to-pdf-api
Website technology lookup APIhttps://urlpipe.dev/website-technology-lookup-api
Structured data extraction APIhttps://urlpipe.dev/structured-data-extraction-api
Keyword extraction APIhttps://urlpipe.dev/keyword-extraction-api
URL summarization APIhttps://urlpipe.dev/url-summarization-api
Web access for AI agentshttps://urlpipe.dev/use-cases/ai-agents
Web pages into a RAG pipelinehttps://urlpipe.dev/use-cases/rag-ingestion
Link previews and unfurlshttps://urlpipe.dev/use-cases/link-previews
Monitoring client websiteshttps://urlpipe.dev/use-cases/client-site-monitoring
Monitoring pages for changeshttps://urlpipe.dev/use-cases/content-monitoring
Archiving pages as screenshotshttps://urlpipe.dev/use-cases/visual-archiving
URL features inside a multi-tenant apphttps://urlpipe.dev/use-cases/multi-tenant-apps
Free toolshttps://urlpipe.dev/tools
Docshttps://urlpipe.dev/docs
Pricinghttps://urlpipe.dev/pricing
Guideshttps://urlpipe.dev/guides
Code recipeshttps://urlpipe.dev/code
Glossaryhttps://urlpipe.dev/glossary
Researchhttps://urlpipe.dev/research
Comparehttps://urlpipe.dev/compare
Changeloghttps://urlpipe.dev/changelog
Engineering noteshttps://urlpipe.dev/notes
Start freehttps://urlpipe.dev/auth/sign-up/new
Sign inhttps://urlpipe.dev/auth/session/new
Roger Camposhttps://rogercampos.com
Start freehttps://urlpipe.dev/auth/sign-up/new
See the APIhttps://urlpipe.dev/#endpoints
/lighthousehttps://urlpipe.dev/docs/lighthouse
guide to reading a Lighthouse audithttps://urlpipe.dev/guides/how-to-read-a-lighthouse-audit
docs pagehttps://urlpipe.dev/docs/lighthouse
Full Stack Audithttps://fullstackaudit.com
Run a Lighthouse audit on any URLPaste a link and get a real Google Lighthouse audit — performance, accessibility, best practices and SEO scores, plus Core Web Vitals — measured against the live page.Try it freehttps://urlpipe.dev/tools/lighthouse-audit
/lighthouse API docshttps://urlpipe.dev/docs/lighthouse
Client libraries in the docshttps://urlpipe.dev/docs/client-libraries
Python client on GitHubhttps://github.com/URLpipe/urlpipe-python
Node.jshttps://urlpipe.dev/code/node/lighthouse-audit
PHPhttps://urlpipe.dev/code/php/lighthouse-audit
Rubyhttps://urlpipe.dev/code/ruby/lighthouse-audit
Gohttps://urlpipe.dev/code/go/lighthouse-audit
Javahttps://urlpipe.dev/code/java/lighthouse-audit
C#https://urlpipe.dev/code/csharp/lighthouse-audit
cURLhttps://urlpipe.dev/code/curl/lighthouse-audit
every Python recipehttps://urlpipe.dev/code/python
Best Lighthouse APIshttps://urlpipe.dev/best-lighthouse-apis
Request timing as marks, not spanshttps://urlpipe.dev/notes/request-timing-as-marks
Reading a Lighthouse audithttps://urlpipe.dev/guides/how-to-read-a-lighthouse-audit
Total Blocking Time (TBT)https://urlpipe.dev/glossary/total-blocking-time
Time to First Byte (TTFB)https://urlpipe.dev/glossary/time-to-first-byte
Lighthousehttps://urlpipe.dev/docs/lighthouse
All of code recipeshttps://urlpipe.dev/code
Start freehttps://urlpipe.dev/auth/sign-up/new
URLpipehttps://urlpipe.dev/
Web scraping APIhttps://urlpipe.dev/web-scraping-api
URL to Markdown APIhttps://urlpipe.dev/url-to-markdown-api
MCP serverhttps://urlpipe.dev/mcp-server
Screenshot APIhttps://urlpipe.dev/screenshot-api
Lighthouse APIhttps://urlpipe.dev/lighthouse-api
Metadata APIhttps://urlpipe.dev/metadata-api
Console APIhttps://urlpipe.dev/console-api
Rendered HTML APIhttps://urlpipe.dev/rendered-html-api
URL to PDF APIhttps://urlpipe.dev/url-to-pdf-api
Website technology lookup APIhttps://urlpipe.dev/website-technology-lookup-api
Structured data extraction APIhttps://urlpipe.dev/structured-data-extraction-api
Keyword extraction APIhttps://urlpipe.dev/keyword-extraction-api
URL summarization APIhttps://urlpipe.dev/url-summarization-api
Free toolshttps://urlpipe.dev/tools
Pricinghttps://urlpipe.dev/pricing
Docshttps://urlpipe.dev/docs
Client librarieshttps://urlpipe.dev/docs/client-libraries
Guideshttps://urlpipe.dev/guides
Code recipeshttps://urlpipe.dev/code
Use caseshttps://urlpipe.dev/use-cases
Integrationshttps://urlpipe.dev/integrations
Glossaryhttps://urlpipe.dev/glossary
Researchhttps://urlpipe.dev/research
Engineering noteshttps://urlpipe.dev/notes
Changeloghttps://urlpipe.dev/changelog
llms.txthttps://urlpipe.dev/llms.txt
All comparisonshttps://urlpipe.dev/compare
URLpipe vs Firecrawlhttps://urlpipe.dev/compare/urlpipe-vs-firecrawl
URLpipe vs Jina Readerhttps://urlpipe.dev/compare/urlpipe-vs-jina-reader
Best HTML-to-Markdown APIshttps://urlpipe.dev/best-html-to-markdown-apis
Jina Reader alternativeshttps://urlpipe.dev/alternatives/jina-reader
Microlink alternativeshttps://urlpipe.dev/alternatives/microlink
ScreenshotOne alternativeshttps://urlpipe.dev/alternatives/screenshotone
Abouthttps://urlpipe.dev/about
Securityhttps://urlpipe.dev/security
Statushttps://urlpipe.dev/status
GitHubhttps://github.com/URLpipe
Privacyhttps://urlpipe.dev/privacy
Termshttps://urlpipe.dev/terms
Sign inhttps://urlpipe.dev/auth/session/new
Legal noticehttps://urlpipe.dev/terms#legal-notice
Roger Camposhttps://rogercampos.com

Viewport: width=device-width,initial-scale=1


URLs of crawlers that visited me.