https://github.com/rexhang/node-puppeteer-serve
使用 puppeteer 进行网站截图 并返回 - by rexhang
https://github.com/rexhang/node-puppeteer-serve
Last synced: about 1 year ago
JSON representation
使用 puppeteer 进行网站截图 并返回 - by rexhang
- Host: GitHub
- URL: https://github.com/rexhang/node-puppeteer-serve
- Owner: rexhang
- License: mit
- Created: 2023-08-08T09:05:46.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-08T09:37:08.000Z (almost 3 years ago)
- Last Synced: 2025-01-24T12:45:41.279Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://github.com/rexhang/node-puppeteer-serve
- Size: 50.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 使用 puppeteer 进行网站截图 并返回
### 1.本地node环境直接使用
```bash
npm install
node app.js
```
服务启动后 访问 :3000/screenshot?url=https://www.qq.com&w=2560&h=1440&w=1920&h=1080
```javascript
url: 要进行截图的网站地址
w: 截图视口的宽度
h: 截图视口的高度
m: json | file 默认json 返回的形式可以是json形式或者直接是图片
```
例如:
>json形式返回
`http://127.0.0.1:3000/screenshot?url=https://www.qq.com&w=2560&h=1440`

>文件形式返回
`http://127.0.0.1:3000/screenshot?url=https://www.qq.com&w=2560&h=1440&m=file`

### 2.docker环境使用(推荐)
使用我提供的image镜像,然后docker构建容器体验即可(注意的是映射端口,服务启动在容器的3000端口,需要映射到本地,具体查看 **[build-container.cmd](https://github.com/rexhang/node-puppeteer-serve/blob/main/build-container.cmd)** 文件)。
**[dockerHub](https://hub.docker.com/)** 中搜索 **`rexhang/docker-node-puppeteer`** pull image **[直达链接](https://hub.docker.com/r/rexhang/docker-node-puppeteer/tags)**

