const request = require('request');
const cheerio = require("cheerio");
const iconv = require('iconv-lite')
let url = 'http://m.17dm.com/wugengji/manhua/124112.html'
request(url,function (error, response, body) {
if(response && response.statusCode == 200){
var html = iconv.decode(body.toString(),'gb2312');
var $ = cheerio.load(html)
}
console.log($('select[name="listNarImg"]').children("option:last-child").attr("value"))
});
// http://img.17dm.com/wugengji/manhua/2b21/17.jpg
const request = require('request');
const fs= require('fs')
let page = 8;
let setion = 21
let chapter = 2
async function downloadImage() {
let url = `http://img.17dm.com/wugengji/manhua/${chapter}b${setion}/${page}.jpg`;
if (!fs.existsSync(`wugeng/${chapter}`)) {//查看是否存在这个文件夹
fs.mkdirSync(`wugeng/${chapter}`);
}
if (!fs.existsSync(`wugeng/${chapter}/${setion}`)) {//查看是否存在这个文件夹
fs.mkdirSync(`wugeng/${chapter}/${setion}`);//不存在就建文件夹
console.log(`wugeng/${chapter}/${setion} 文件夹创建成功`);
} else {
console.log(`wugeng/${chapter}/${setion} 文件夹已经存在`);
}
let headers ={
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36',
'Connection':'keep-alive'
};
await request({
url: url,
encoding: 'binary'
},function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log('开始下载')
if(!body) console.log("(╥╯^╰╥)哎呀没有内容。。。")
fs.writeFile(`wugeng/${chapter}/${setion}/${page}.jpg`,body, 'binary', function (err) {
if (err) {console.log(err);}
console.log(`wugeng/${chapter}/${setion}/${page}.jpg 下载成功`);
})
}
setTimeout(()=>{
page++
if(page == 34){
setion++
page = 1
}
if(setion == 64){
chapter = 3
setion = 1;
page = 1
}
downloadImage()
},300)
})
}
downloadImage()
网友评论