Skip to content

Instantly share code, notes, and snippets.

@arm5077
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save arm5077/00bcb24db7cc1957fffa to your computer and use it in GitHub Desktop.

Select an option

Save arm5077/00bcb24db7cc1957fffa to your computer and use it in GitHub Desktop.
Scrapes Clinton Benghazi emails from the State Department's open records website
var fs = require("fs");
var http = require('http');
fs.readFile("data.json", 'utf8', function(err, data){
data = JSON.parse(data);
data.Results.forEach(function(email, i){
console.log("http://foia.state.gov/searchapp/"+email.pdfLink);
// use a timeout so State's server doesn't get mad
setTimeout(function(){
var file = fs.createWriteStream(Date.now() + ".pdf");
var request = http.get("http://foia.state.gov/searchapp/"+email.pdfLink, function(response) {
response.pipe(file);
});
}, i*500);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment