Giter Club home page Giter Club logo

screenshot-and-upload-to-ali-oss's Introduction

一键截图、压缩 & 上传至阿里 OSS

截取指定网站首页图片(png),在使用 TinyPNG 压缩后,上传至指定阿里云 OSS,并返回相关信息。

背景哲学

倾城之链,旨在云集全球优秀网站,方便你我探索互联网中更广阔的世界。在倾城,您可以分享(提交)所欢喜的网站;后台将自动为所提交网站首页进行截图、压缩、并上传至阿里云 OSS,从而在对应介绍页引用,展示给用户。此仓库旨在将相关代码提取出来,并做封装处理,分享给有类似需求的朋友。

如何使用

安装依赖

git clone https://github.com/nicejade/screenshot-and-upload-to-ali-oss.git
cd screenshot-and-upload-to-ali-oss
yarn

额外地,您需要安装 screenshoteer。自动化为指定网页截图,在 Node.js 领域,最好用的工具莫过于谷歌公司所推出的 puppeteer,功能强大,使用简单。而 screenshoteer 是对 puppeteer 的再封装,使用起来更为方便,因此就直接用了它。具体安装方式如下:

Make website screenshots and mobile emulations from the command line.

yarn add global screenshoteer
# Or
npm i screenshoteer -g

隐私配置

考虑到要上传至 OSS,其中需要用到些私密配置;因此,这里需要您自行配置;只需在根目录下,创建 secret.config.js 文件,具体内容与格式,可以参考 secret.config.example.js。

对于其中字段需要说明下, tinifyKey 为 TinyPNG 压缩秘钥;使用邮箱登录 TinyPNG,即可根据免费🆓账号生成 API Key,可供每月 500 张图片压缩处理。其余四个字段,皆为阿里云 OSS 所需,在其后台操作下,即可获得。需要说明下的是,它功能强大,支持对图片做各种处理(加水印、格式转换等);价格按所用收费,相对较为便宜。

使用命令

在项目根目录下,可以基于 npm link 命令,将 screenshot 命令 link 至全局,即可方便使用;具体操作方式如下:

screenshot --url http://nicelinks.site/
# OR
screenshot --url http://nicelinks.site/ -ns -nu
# OR
screenshot --url http://nicelinks.site/ -nt -nu

参数说明

参数 简写 功能描述
--url -u 指定要截图网站的 url 地址.
--noscreenshot -ns 无需截图,上传本地图片.
--notinify -nt 不压缩图片,直接上传.
--noupload -nu 不上传截图至指定的 OSS.

相关链接

License

MIT

Copyright (c) 2020-present, nicejade.

screenshot-and-upload-to-ali-oss's People

Contributors

nicejade avatar

Stargazers

ABpasser avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.