Skip to content

Instantly share code, notes, and snippets.

@aanton
Created June 19, 2013 08:43
Show Gist options
  • Save aanton/5812729 to your computer and use it in GitHub Desktop.
Save aanton/5812729 to your computer and use it in GitHub Desktop.
Get all videos URLs of a week in a course from education.10gen.com using web scrapping, javascript, jquery and browser console
/*
Instructions:
1. Log in with your account and go to the desired course
2. Open the courseware tab
3. Configure the week variable
4. Copy this code and paste it in the browser console
*/
var week = 1;
var urls = [];
jQuery('nav ul[role=tabpanel]:eq(' + (week-1) + ') li').each(function() {
urls.push(jQuery(this).find('a').attr('href'));
});
var codes = [];
var regex = /data-streams="1.0:(.*?)"/gi, result;
jQuery.each(urls, function (index, value) {
jQuery.ajax(value, {
'async': false,
'dataType': 'html',
'success': function(data) {
while ( (result = regex.exec(data)) )
{
codes.push(result[1]);
}
}
});
// return false; // break bucle
});
jQuery.each(codes, function(index, value) {
console.log('http://www.youtube.com/watch?v=' + value);
});
console.log('Number of videos in the week ' + week + ': ' + codes.length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment