Skip to content

Instantly share code, notes, and snippets.

@musou1500
Created September 4, 2017 17:12
Show Gist options
  • Save musou1500/beac16f2ca61c35956301b0ed33566d0 to your computer and use it in GitHub Desktop.
Save musou1500/beac16f2ca61c35956301b0ed33566d0 to your computer and use it in GitHub Desktop.
今日のうんちは何かな? https://shindanmaker.com/518611
const crypto = require('crypto');
const cheerio = require('cheerio');
const fetch = require('node-fetch');
const FormData = require('form-data');
function fetchUntilMatch(postInterval = 500) {
const input = crypto.randomBytes(8).toString('hex');
fetchResult(input)
.then(result => {
console.log(`${input} => ${result}`);
if (!result.startsWith('うんち')) {
setTimeout(() => fetchUntilMatch(postInterval), postInterval);
}
});
}
function fetchResult(input) {
const fd = new FormData();
fd.append('u', input)
return fetch('https://shindanmaker.com/518611', {
method: 'POST',
body: fd,
headers: fd.getHeaders()
}).then(res => res.text())
.then(html => cheerio.load(html))
.then($ => $('.result2').text().trim());
}
fetchUntilMatch(500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment