当前位置:网站首页>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 (3) -- Metasploit framework (MSF)
- Cost accounting [13]
- 【练习-9】Zombie’s Treasure Chest
- Penetration test (8) -- official document of burp Suite Pro
- Research Report on surgical fluid treatment industry - market status analysis and development prospect prediction
- Cost accounting [16]
- 0-1 knapsack problem (I)
- Accounting regulations and professional ethics [2]
- C语言是低级和高级的分水岭
- 动态规划前路径问题
猜你喜欢
Nodejs+vue网上鲜花店销售信息系统express+mysql
[exercise-7] crossover answers
X-Forwarded-For详解、如何获取到客户端IP
数据在内存中的存储&载入内存,让程序运行起来
Penetration testing (5) -- a collection of practical skills of scanning King nmap and penetration testing tools
C语言是低级和高级的分水岭
Ball Dropping
用C语言写网页游戏
Borg Maze (BFS+最小生成树)(解题报告)
【高老师UML软件建模基础】20级云班课习题答案合集
随机推荐
想应聘程序员,您的简历就该这样写【精华总结】
Borg Maze (BFS+最小生成树)(解题报告)
Opencv learning log 14 - count the number of coins in the picture (regardless of overlap)
【练习-9】Zombie’s Treasure Chest
MySQL import database error [err] 1273 - unknown collation: 'utf8mb4_ 0900_ ai_ ci’
X-forwarded-for details, how to get the client IP
HDU - 6024 Building Shops(女生赛)
Research Report on shell heater industry - market status analysis and development prospect forecast
SSM框架常用配置文件
[analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class
Opencv learning log 19 skin grinding
信息安全-安全编排自动化与响应 (SOAR) 技术解析
差分(一维,二维,三维) 蓝桥杯三体攻击
用C语言写网页游戏
Information security - Analysis of security orchestration automation and response (soar) technology
毕业才知道IT专业大学生毕业前必做的1010件事
Record of force deduction and question brushing
Cost accounting [17]
渗透测试 ( 5 ) --- 扫描之王 nmap、渗透测试工具实战技巧合集
Opencv learning log 16 paperclip count