Created
February 9, 2020 14:26
-
-
Save rainb3rry/c622f4e0147dea977d97495fe867f2fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('request') | |
const fs = require('graceful-fs') | |
fs.readFile('data.txt', 'utf-8', (err, res) => { | |
var data = res.replace(/<BR>/g, '\n').split('\n').map(val => (val.substr(0, 1) != '.') ? val : val.substr(1, val.length - 1)).slice(0, -1) | |
function go(count) { | |
var link = 'http://' + data[count] | |
request(link, {forever: false, timeout: 15000}, function(err, response, body) { | |
if (!err) { | |
console.log(response.statusCode + ': ' + link) | |
if (response.statusCode == 200) { | |
fs.appendFileSync('ok.txt', link + '\n') | |
} | |
} else { | |
console.log('err: ' + err.code + '|' + link) | |
} | |
if (count < data.length) { | |
go(count + 1) | |
} else { | |
console.log('finished: ' + Date()) | |
} | |
}) | |
} | |
console.log('started: ' + Date()) | |
go(0) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment