Skip to content

Instantly share code, notes, and snippets.

@westc
Created January 9, 2019 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westc/460eb1d5d61edd014d2df8e4e8e24017 to your computer and use it in GitHub Desktop.
Save westc/460eb1d5d61edd014d2df8e4e8e24017 to your computer and use it in GitHub Desktop.
Get all of the movies listed on dl.tehmovies.pro.
// Navigate to any URL in the http://dl.tehmovies.pro/94/ domain and then run this code:
(function () {
var movies = [];
var urls = ['http://dl.tehmovies.pro/94/'];
function explore(rgxURL) {
var url = urls.shift();
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onload = function () {
if (xhr.status == 200) {
xhr.responseText.replace(/^<a[^>]*>(?<name>[^>]+)<\/a>\s+(?<dateTime>\d+-\w+-\d+ \d+:\d+)\s+(?<size>[\d\-]+)/gm, function (_, name, dateTime, size) {
if (+size) {
movies.push({ url: url + name, dateTime: new Date(dateTime), size: +size });
}
else if (!rgxURL || rgxURL.test(url + name)) {
urls.push(url + name);
}
});
}
if (urls.length) {
console.log(urls.length + ' left | collected ' + movies.length + ' | ' + url + '...');
explore();
}
else {
console.log('Done...', movies);
}
delete url;
delete xhr;
};
xhr.send();
}
explore(/\/94\/\d+\//);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment