Created
January 9, 2019 03:43
-
-
Save westc/460eb1d5d61edd014d2df8e4e8e24017 to your computer and use it in GitHub Desktop.
Get all of the movies listed on dl.tehmovies.pro.
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
// 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