47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
var URL = "http://m.imomoe.in/";
|
|
// var iconv = require('iconv-lite');
|
|
const cheerio = require('cheerio');
|
|
const fs = require("fs")
|
|
const request = require('request');
|
|
|
|
var infoHtml = 'https://www.90tu.com/xingganmeinv/8552.html';
|
|
|
|
// request('https://www.90tu.com/xingganmeinv/', function (error, response, body) {
|
|
// console.log(body);
|
|
// var $ = cheerio.load(body)
|
|
// $(".clearh10").parent().find("ul li").each(function(){
|
|
// let imgUrl = $(this).find("img").attr("src")
|
|
// console.log();
|
|
// request(imgUrl).pipe(fs.createWriteStream(`./img/${$(this).find("span").text()}.png`))
|
|
// });
|
|
// });
|
|
|
|
request(infoHtml, function (error, response, body) {
|
|
var $ = cheerio.load(body)
|
|
let lastA = $(".page1 a")[$(".page1 a").length - 1];
|
|
var url = $(lastA).attr("href");
|
|
var totalPage = url.match(/_([\s\S]*?).html/)[1];
|
|
|
|
for (var i=1;i<=totalPage;i++) {
|
|
if (i == 1) {
|
|
DownImg($(".spanlr a img").attr("src"))
|
|
} else {
|
|
let a = `https://www.90tu.com/xingganmeinv/8552_${i}.html`
|
|
console.log(a);
|
|
get(a)
|
|
}
|
|
}
|
|
});
|
|
|
|
function get(url) {
|
|
request(url, function (error, response, body) {
|
|
var $ = cheerio.load(body);
|
|
DownImg($(".spanlr a img").attr("src"))
|
|
})
|
|
}
|
|
|
|
|
|
|
|
function DownImg(url) {
|
|
request(url).pipe(fs.createWriteStream(`./img/${Math.random(0,100)}${(new Date()).valueOf()}.png`))
|
|
} |