1 Star 0 Fork 0

wx-rdc / webpage-getter

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

WebpageGetter

Nodejs版本的网页另存功能。

调用示例

const { WebpageGetter } = require('webpage-getter');

let webpageGetter = new WebpageGetter();

// url: https://www.whatyouwant.com/

// content: 网页渲染后的内容,通常可以使用无头浏览器或者[splash]()来自动获取

// 你可以使用其它方式生成目标名
const dest = webpageGetter.genIdentifier();

webpageGetter.saveAs(url, content, dest).then(() => {
    log(dest, " save done.");
})

致谢

本项目来源于 Raymond HewebpageGetter 项目,由 Edward Zhu 进行了改写,修复了若干Bug,并生成NPM包。

命令行使用帮助

本项目仍然保留了命令行的使用方式,你可以执行如下命令启动命令行工具

webpageGetter

下面是原作者的使用说明:

这个小工具被设计用来下载你正在浏览的网页及其关联的资源文件。 所谓关联的资源文件包括图像,样式文件,脚本文件等等。 针对样式文件,其所引用的图像文件也会被保存下来。 使用这个工具需要提供实际的网页内容而不是最初由服务器返回的HTML。 这是因为一些网页只有当你滚动到页面最下端或者等待脚本文件执行完毕,才会真正渲染完成。

保存网页前,需要你提供:

  1. 网址,例如 "https://www.whatyouwant.com/"
  2. 实际的网页内容。 拿Chrome举例, 你可以这样获得实际的网页内容: 打开开发者工具, 切换到Elements标签, 右击 html 元素, 出现上下文菜单, 选择 Copy > Copy outerHTML。 最终, 你会得到一个HTML文件 - YYMMDDHHMMSS.html 和一个资源文件夹 - YYMMDDHHMMSS。 希望这个工具能对大家有点儿小用! -- "Raymond He"
MIT License Copyright (c) 2021 wuxi research and development centre Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

类似网页另存功能,能够解析并下载页面中的所有资源,并改写原始HTML,使得最终得到的HTML页面能够进行离线浏览。提供Nodejs接口调用,便于集成到项目中。 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/wx-rdc/webpage-getter.git
git@gitee.com:wx-rdc/webpage-getter.git
wx-rdc
webpage-getter
webpage-getter
master

搜索帮助