node-图片爬虫

126 阅读1分钟

node-图片爬虫

请求接口路径:www.jianshu.com/p/fb1d1ad58…

实现效果:

image-20220703152511500.png

image-20220703152532593.png

how to use

node index.js

会自动创建文件夹,然后下载文件下来

项目结构 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 仓库:

downloadpic

欢迎访问我的其他项目:

md 文件转换为 pdf

GitBook Introduction 教程

使用 mdx 开发一个酷炫的 ppt

学习用 ts+gulp+rollup 写一个工具库