Created
June 5, 2014 12:17
-
-
Save lstroud/b648bc418869785c3cc5 to your computer and use it in GitHub Desktop.
Download 2014 WWDC Slides (PDFs)
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
var request = require('request'); | |
var cheerio = require('cheerio'); | |
var fs = require('fs'); | |
var auth = { | |
'user': 'appleid', | |
'pass': 'mypassword', | |
'sendImmediately': false | |
}; | |
request.get('https://developer.apple.com/videos/wwdc/2014/', { | |
'auth': auth | |
},function (error, response, body) { | |
if (!error && response.statusCode == 200) { | |
$ = cheerio.load(body); | |
var links = $('a').filter(function (i, el){ | |
return $(this).attr('href').indexOf(".pdf") > 0; | |
}); | |
links.each(function(i, el){ | |
var _href = $(this).attr('href'); | |
var _filename = _href.replace(/\?.*$/,"").replace(/.*\//,""); | |
console.log("Downloading " + _filename + " ... "); | |
var _dest = __dirname + "/" + _filename; | |
var _r = request(_href, {'auth': auth}).pipe(fs.createWriteStream(_dest)); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment