当前位置:网站首页>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
边栏推荐
- Penetration test (1) -- necessary tools, navigation
- Information security - security professional name | CVE | rce | POC | Vul | 0day
- Research Report on shell heater industry - market status analysis and development prospect forecast
- 【高老师软件需求分析】20级云班课习题答案合集
- Cost accounting [13]
- Information security - threat detection - detailed design of NAT log access threat detection platform
- [exercise-8] (UVA 246) 10-20-30== simulation
- 【练习-7】Crossword Answers
- X-forwarded-for details, how to get the client IP
- 0-1背包问题(一)
猜你喜欢

X-forwarded-for details, how to get the client IP

STM32 learning record: LED light flashes (register version)

用C语言写网页游戏

Penetration test (8) -- official document of burp Suite Pro

滲透測試 ( 1 ) --- 必備 工具、導航

Information security - Epic vulnerability log4j vulnerability mechanism and preventive measures

差分(一维,二维,三维) 蓝桥杯三体攻击

b站 实时弹幕和历史弹幕 Protobuf 格式解析

B - 代码派对(女生赛)

信息安全-威胁检测-NAT日志接入威胁检测平台详细设计
随机推荐
1010 things that college students majoring in it must do before graduation
[exercise-3] (UVA 442) matrix chain multiplication
Gartner: five suggestions on best practices for zero trust network access
0 - 1 problème de sac à dos (1)
【练习-1】(Uva 673) Parentheses Balance/平衡的括号 (栈stack)
Information security - security professional name | CVE | rce | POC | Vul | 0day
[exercise-2] (UVA 712) s-trees
毕业才知道IT专业大学生毕业前必做的1010件事
Cost accounting [22]
Information security - Analysis of security orchestration automation and response (soar) technology
Research Report on market supply and demand and strategy of geosynthetics industry in China
信息安全-威胁检测引擎-常见规则引擎底座性能比较
C语言必背代码大全
Perinatal Software Industry Research Report - market status analysis and development prospect forecast
Accounting regulations and professional ethics [4]
C语言学习笔记
HDU-6025-Coprime Sequence(女生赛)
[exercise-7] crossover answers
渗透测试 ( 8 ) --- Burp Suite Pro 官方文档
China's PCB connector market trend report, technological innovation and market forecast