Saving an HTML report | lighthouse-rust | Spatie      

 SPATIE  

lighthouse-rust
===============

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Lighthouse-rust](https://spatie.be/docs/lighthouse-rust/v1)  Usage  Saving an HTML report

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/lighthouse-rust/v1) 

  Saving an HTML report    
- [ Introduction ](https://spatie.be/docs/lighthouse-rust/v1/introduction)
- [ Support us ](https://spatie.be/docs/lighthouse-rust/v1/support-us)
- [ Requirements ](https://spatie.be/docs/lighthouse-rust/v1/requirements)
- [ Installation &amp; setup ](https://spatie.be/docs/lighthouse-rust/v1/installation-setup)
- [ Testing ](https://spatie.be/docs/lighthouse-rust/v1/testing)
- [ Changelog ](https://spatie.be/docs/lighthouse-rust/v1/changelog)

Usage
-----

- [ Generating your first report ](https://spatie.be/docs/lighthouse-rust/v1/usage/generating-your-first-report)
- [ Configuring a run ](https://spatie.be/docs/lighthouse-rust/v1/usage/configuring-a-run)
- [ Working with results ](https://spatie.be/docs/lighthouse-rust/v1/usage/working-with-results)
- [ Saving an HTML report ](https://spatie.be/docs/lighthouse-rust/v1/usage/saving-an-html-report)
- [ Using performance budgets ](https://spatie.be/docs/lighthouse-rust/v1/usage/using-performance-budgets)

 Saving an HTML report
=====================

Lighthouse can generate a nicely formatted HTML report with the scores and results of all audits.

```
Lighthouse::url("https://example.com")?
    .run()?
    .save_html("report.html")?;
```

This is how that report looks in the browser. The screenshot comes from the original PHP documentation; current Lighthouse versions may render it differently.

![Lighthouse HTML report](https://spatie.be/docs/lighthouse-php/v2/images/report.jpg)

To get the HTML without saving it to a file, call `html()`.

```
let result = Lighthouse::url("https://example.com")?.run()?;
let html = result.html();
```

`html()` borrows the result's HTML string. `save_html()` overwrites the file and returns a filesystem error if it cannot write it. It does not create missing parent directories.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
