Skip to content

Instantly share code, notes, and snippets.

@rainb3rry
Created February 9, 2020 14:26
Show Gist options
  • Select an option

  • Save rainb3rry/c622f4e0147dea977d97495fe867f2fa to your computer and use it in GitHub Desktop.

Select an option

Save rainb3rry/c622f4e0147dea977d97495fe867f2fa to your computer and use it in GitHub Desktop.

Revisions

  1. rainb3rry created this gist Feb 9, 2020.
    33 changes: 33 additions & 0 deletions sub.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    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)

    })