node-图片爬虫
请求接口路径:https://www.jianshu.com/p/fb1d1ad58a0b
实现效果:
项目结构 tree
├───request.json ---请求配置
├───downloadPic ---下载图片的包
├───downloadZHIHUPic ---下载知乎的,已弃用
└───index ---主入口
搭建过程
download
是 npm 大神 sindresorhus 写的,非常好用
npm install download
下面是从网站下载图片的代码。下载函数接收文件和文件路径。
const download = require("download");
// Url of the image
const file = "GFG.jpeg";
// Path at which image will get downloaded
const filePath = `${__dirname}/files`;
download(file, filePath).then(() => {
console.log("Download Completed");
});
完整代码请查看 github 仓库:
欢迎访问我的其他项目:
md 文件转换为 pdf
GitBook Introduction 教程
使用 mdx 开发一个酷炫的 ppt
学习用 ts+gulp+rollup 写一个工具库