当前位置:网站首页>Nodejs crawler
Nodejs crawler
2022-07-06 15:59:00 【Star age Cao Botao】
nodejs You can also play with reptiles
Need to pass through npm Down in two modules .
npm init -y
npm install -S axios cheerio
establish index.js file
const cheerio = require("cheerio")
const axios = require("axios")
const fs = require("fs")
if (!fs.existsSync("download")) {
fs.mkdirSync("download", 777)
}
console.log(" Start crawling ")
axios.get("http://www.scsoul.top/list/1/20").then(r => {
const $ = cheerio.load(r.data)
$("img").each((index, item) => {
if (index != 0) {
var url = $(item).attr("src");
console.log(" Start the download " + url)
axios.get(url, {
responseType: 'stream' }).then(resp => {
let writer = fs.createWriteStream("./download/" + index + ".png");
resp.data.pipe(writer);
console.log(index+".png Download complete ")
})
}
})
})
cmd Input
node index.js
You can see that the file has been downloaded
边栏推荐
- 【练习-6】(PTA)分而治之
- 【练习-8】(Uva 246)10-20-30==模拟
- [exercise-7] crossover answers
- Penetration test (3) -- Metasploit framework (MSF)
- b站 实时弹幕和历史弹幕 Protobuf 格式解析
- Indonesian medical sensor Industry Research Report - market status analysis and development prospect forecast
- MySQL授予用户指定内容的操作权限
- Alice and Bob (2021牛客暑期多校训练营1)
- Research Report on surgical fluid treatment industry - market status analysis and development prospect prediction
- 【练习4-1】Cake Distribution(分配蛋糕)
猜你喜欢

VS2019初步使用
![[exercise-5] (UVA 839) not so mobile (balance)](/img/8e/48dcf75f7347b36301df6fc129c09d.png)
[exercise-5] (UVA 839) not so mobile (balance)

Penetration test (1) -- necessary tools, navigation

Optimization method of path problem before dynamic planning

Nodejs+vue online fresh flower shop sales information system express+mysql

Determine the Photo Position

C语言学习笔记

【高老师UML软件建模基础】20级云班课习题答案合集

STM32如何使用STLINK下载程序:点亮LED跑马灯(库版本)

【高老师软件需求分析】20级云班课习题答案合集
随机推荐
C语言数组的概念
Gartner:关于零信任网络访问最佳实践的五个建议
【练习4-1】Cake Distribution(分配蛋糕)
China's peripheral catheter market trend report, technological innovation and market forecast
Penetration test (2) -- penetration test system, target, GoogleHacking, Kali tool
信息安全-威胁检测-NAT日志接入威胁检测平台详细设计
信息安全-史诗级漏洞Log4j的漏洞机理和防范措施
Accounting regulations and professional ethics [1]
D - Function(HDU - 6546)女生赛
【练习-3】(Uva 442)Matrix Chain Multiplication(矩阵链乘)
Penetration testing (5) -- a collection of practical skills of scanning King nmap and penetration testing tools
Ball Dropping
【高老师UML软件建模基础】20级云班课习题答案合集
初入Redis
TCP的三次握手与四次挥手
China's earthwork tire market trend report, technical dynamic innovation and market forecast
China's salt water membrane market trend report, technological innovation and market forecast
7-1 懂的都懂 (20 分)
信息安全-安全专业名称|CVE|RCE|POC|VUL|0DAY
X-Forwarded-For详解、如何获取到客户端IP