[Node.js] Web Scraping Images with Node, Xray, and Download
2023-09-14 08:59:20 时间
Node makes scraping images off the web extremely easy using a couple handy packages: Xray and Download. Simple scrape the img tag, grab all the src attributes, filter out images you don't want, then hand them over to Download to grab them.
var Xray = require('x-ray'); var fs = require('fs'); var Download = require('download'); var xray = new Xray(); xray('https://en.wikipedia.org/wiki/Pluto', 'img', [{ img: '', src: '@src', width: '@width', height: '@height' }] ) (function(err, results) { var download = new Download(); results = results.filter(function(image) { return image.width > 100; }).forEach(function(image) { download.get(image.src); }); download.dest('./images'); download.run(); fs.writeFile("./results.json", JSON.stringify(results, null, '\t')); })
相关文章
- node.js(3)
- 「Node.js」白露欲霜,聊聊zlib压缩
- JS对象转数组_js怎么把数组转成对象
- Node.js笔记
- 【JS 逆向百例】猿人学系列 web 比赛第二题:js 混淆 - 动态 cookie,详细剖析
- get两个js小技能——JS截取视频第一帧&图片转Base64
- linux 下 Node.js 开发环境搭建详解程序员
- ThinkJS 3 正式版发布,Node.js Web 框架详解编程语言
- Node.js中的Buffer对象详解编程语言
- 快速在Linux平台上安装Node.js(node安装linux)
- express使用Node.js、MongoDB和Express快速构建Web应用(nodemongodb)
- Node.js连接MSSQL数据库的操作指南(node 链接mssql)
- 利用Node.js实现对MS SQL服务器的连接(node连MSsql)
- Node.js和MSSQL数据库的完美结合:使用node mssql模块(node mssql模块)
- 使用Node.js链接/操作MS SQL数据库(node mssql使用)
- JavaScript驱动的Oracle数据库访问方式(js访问oracle)
- 刷新时清空文本框内容的js代码
- 往光标所在位置插入值的js代码
- JS中Date日期函数中的参数使用介绍
- 跟我学Nodejs(三)---Node.js模块
- NODE.JS加密模块CRYPTO常用方法介绍
- node.js中的fs.truncate方法使用说明
- 我的Node.js学习之路(三)--node.js作用、回调、同步和异步代码以及事件循环
- 在Linux上用forever实现Node.js项目自启动
- Node.js开发之访问Redis数据库教程
- JS中产生20位随机数以0-9为例也可以是a-zA-Z
- Node.js文件操作详解
- node.js中使用q.js实现api的promise化