browsershot
5,250
Stars
0
Forks
0
Watchers
0
Open Issues
未知
许可证
PHP
语言
创建时间
最近更新
项目能做什么
将 HTML 转换为图片、PDF 或字符串的工具。
来源:AI 基于仓库事实生成
· 内容以仓库实际 README 为准
使用说明 查看原始 README 原仓库文档
中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
<div align="left">
<a href="https://spatie.be/open-source?utm_source=github&utm_medium=banner&utm_campaign=browsershot">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://spatie.be/packages/header/browsershot/html/dark.webp">
<img alt="Logo for Browsershot" src="https://spatie.be/packages/header/browsershot/html/light.webp">
</picture>
</a>
<h1>Render web pages to an image or PDF with Puppeteer</h1>
[](https://github.com/spatie/browsershot/releases)
[](LICENSE.md)
[](https://github.com/spatie/browsershot/actions)
[](https://packagist.org/packages/spatie/browsershot)
</div>
The package can convert a web page to an image or PDF. The conversion is done behind the scenes by [Puppeteer](https://github.com/GoogleChrome/puppeteer) which runs a headless version of Google Chrome.
Here's a quick example:
```php
use Spatie\Browsershot\Browsershot;
// an image will be saved
Browsershot::url('https://example.com')->save($pathToImage);
```
It will save a PDF if the path passed to the `save` method has a `pdf` extension.
```php
// a pdf will be saved
Browsershot::url('https://example.com')->save('example.pdf');
```
You can also use an arbitrary html input, simply replace the `url` method with `html`:
```php
Browsershot::html('<h1>Hello world!!</h1>')->save('example.pdf');
```
Local file requests from `html()` are blocked by default, including absolute filesystem paths and JavaScript-generated file URLs. If your trusted HTML needs local assets, opt in with `Browsershot::html($html)->allowLocalFileAccess()->save('example.pdf')`. This permits access to any local file readable by Chrome; only enable it for trusted HTML. Browsershot is not a sandbox for untrusted content.
If your HTML input is already in a file locally use the :
```php
Browsershot::htmlFromFilePath('/local/path/to/file.html')->save('example.pdf');
```
Browsershot also can get the body of an html page after JavaScript has been executed:
```php
Browsershot::url('https://example.com')->bodyHtml(); // returns the html of the body
```
If you wish to retrieve an array list with all of the requests that the page triggered you can do so:
```php
$requests = Browsershot::url('https://example.com')
->triggeredRequests();
foreach ($requests as $request) {
$url = $request['url']; //https://example.com/
}
```
To use Chrome's new [headless mode](https://developers.google.com/web/updates/2017/04/headless-chrome) pass the `newHeadless` method:
```php
Browsershot::url('https://example.com')->newHeadless()->save($pathToImage);
```
## Support us
Learn how
阅读完整原文
商业机会分析 AI 生成
Hosted Browsershot / Chrome-as-a-Service 云端渲染API
| 产品构想 | 构建与Browsershot原生协议无缝兼容的云端Chrome集群API。开发者仅需替换一行连接配置,即可将高负载的Puppeteer渲染卸载到云端,免除本地服务器安装Node、Chrome、字体的运维成本。 |
| 核心功能 | 兼容Browsershot的远程WebSocket/HTTP代理、自动负载均衡与无头浏览器池管理、预置全球多语言字体、反爬/等待网络空闲处理、并发限流与缓存优化。 |
| 目标用户 | 不想在应用服务器维护Chrome环境的中小型Laravel/PHP创业团队与独立开发者。 |
| 难度/周期 | 中等 · 3 - 5 周 · 成本:中(需要持续消耗高内存的云服务器/容器算力)。 |
| 收费模式 | 按API调用量订阅付费(如每月$19包10,000次转换,超额按次计费)。 |
| 竞争风险 | 市面上已有Browserless等通用成熟方案,需重点主打对PHP/Browsershot生态的原生开箱即用支持。 |
| 依据 | 已验证事实 |
Laravel 账单与合同自动化生成引擎 (Invoice & Contract Builder SaaS)
| 产品构想 | 基于Browsershot封装的企业级PDF发票与合同SaaS,提供可视化HTML/CSS模板设计器、数据绑定API与防伪签名图层。 |
| 核心功能 | 拖拽/TailwindCSS模板编辑器、动态分页控制与页码注入、多货币/时区排版、自动压制电子签名与水印、一键导出PDF/图片接口。 |
| 目标用户 | 需要频繁开具PDF收据、发票、订单确认书的电商团队、财务SaaS系统和B2B软件服务商。 |
| 难度/周期 | 中等 · 4 - 8 周 · 成本:低(基础Web全栈开发与少量存储成本)。 |
| 收费模式 | SaaS月付/年付订阅制,提供免费额度,高级版解锁无水印、高级模版与批量并发导出。 |
| 竞争风险 | 模板引擎同质化严重,需要深度契合PHP生态开发者的DX(开发者体验)形成壁垒。 |
| 依据 | 数据支持的判断 |
动态社交分享图(OG Image)自动生成服务
| 产品构想 | 利用Browsershot的网页截图功能,通过URL参数动态渲染HTML组件并生成适配Twitter/微信/OpenGraph的社交分享封面图服务。 |
| 核心功能 | 极速边缘缓存、URL传参动态替换文案与背景、开箱即用的预设社交卡片模版、CDN加速分发。 |
| 目标用户 | 内容创作者、个人博客系统开发者、资讯聚合网站、电子商铺运营者。 |
| 难度/周期 | 低 · 2 - 3 周 · 成本:低(配合Serverless与边缘CDN可有效压低初始成本)。 |
| 收费模式 | 阶梯按量订阅(如免费版每月500张带有水印,付费版按生成的独立图片数量计费)。 |
| 竞争风险 | (推测)需求偏细分,且Vercel/Cloudflare等边缘运行时正逐步提供低成本替代方案。 |
| 依据 | AI推测 |
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心
竞品与相似项目 GitHub Search 真实检索
| 项目 | 中文简介 | Stars | 语言 |
|---|---|---|---|
| EbookFoundation/free-programming-books | 中文介绍暂未生成 :books: Freely available programming books |
401,437 | Python |
| TheAlgorithms/Python | 中文介绍暂未生成 All Algorithms implemented in Python |
226,033 | Python |
| avelino/awesome-go | 中文介绍暂未生成 A curated list of awesome Go frameworks, libraries and softw |
193,380 | Go |
| huggingface/transformers | 中文介绍暂未生成 🤗 Transformers: the model-definition framework for state-of- |
168,883 | Python |
| excalidraw/excalidraw | 中文介绍暂未生成 Virtual whiteboard for sketching hand-drawn like diagrams |
135,524 | TypeScript |
| sherlock-project/sherlock | 中文介绍暂未生成 Hunt down social media accounts by username across social ne |
110,178 | Python |
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。
项目优势与风险
| 技术成熟度 | 创建于 ,最近推送 ,发布过 100 个 Release |
| 社区活跃 | Star 5,250 / Fork 0 / Issue 0(数据支持,可自行核实) |
| 许可证 | 未检测到(需人工确认) |
| 主要风险 | 上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价 |
安装与使用
快速开始(以仓库 README 为准)
git clone https://github.com/spatie/browsershot.git cd browsershot # 请阅读仓库 README 获取确切安装步骤(依赖、配置、启动命令)
术语说明:Docker=应用容器(把程序和依赖打包运行);API Key=调用外部服务的密钥;Git Clone=把仓库代码下载到本地。常见错误:API Key 未配置 / 端口占用 / 数据库连接失败,多数项目在 README 的 Troubleshooting 章节有说明。