1024小玩意😁

Update

2018/12/15 煎蛋网ooxx已和谐 😑

1024

10/24到了,先祝自己节日快乐。同时,1024也是另一个知名网站名,😁。

贴点白嫖来的小玩意,无聊的时候可以点点玩玩。(就选比较和谐的煎蛋网吧)

拷贝新建文件,node执行即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const puppeteer = require('puppeteer');
const axios = require('axios');
const fs = require('fs');
const rimraf = require('rimraf');

if (!fs.existsSync('./result')) {
fs.mkdirSync('./result');
}
if (fs.existsSync('./result/girl')) {
rimraf.sync('./result/girl');
}
fs.mkdirSync('./result/girl');

function getExtension(str = '') {
const dotPos = str.lastIndexOf('.');
if (dotPos > -1) {
return str.substr(dotPos + 1);
}
return 'jpg';
}

let times = 1;
let currentNum = 1;

async function run(url) {
console.log('Start to crawl girl\'s pictures...');
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url);

let images = await page.evaluate(
() => Array.from(document.querySelectorAll('a.view_img_link')).map(e => e.href)
);
images.forEach(async url => {
try {
const res = await axios.get(url, {
responseType: 'stream'
});
res.data.pipe(fs.createWriteStream(`./result/girl/${currentNum}.${getExtension(url)}`));
} catch (e) {
console.log(e);
}
currentNum++;
});
let nextPage = await page.evaluate(() =>
document.querySelectorAll('#comments > div:nth-child(4) > div > a.previous-comment-page')[0].href
);
console.log('OK!');
if (++times > 5) {
browser.close();
console.log('All pictures downloaded complete!')
process.exit(0);
}
setTimeout(function () {
run(nextPage)
}, 5000);
}

run('http://jandan.net/ooxx');

执行后,会出现result文件夹