Created
February 24, 2019 23:10
-
-
Save juliandavidmr/31efe318bf1c42d564b051c1707b3ad1 to your computer and use it in GitHub Desktop.
Get a list of movies from Cinecalidad
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
function getDetailsMovie(htmlString) { | |
var div = document.createElement('div'); | |
div.innerHTML = htmlString.trim(); | |
div = div.querySelectorAll('#content_inside > .post_box'); | |
var listMovies = []; | |
div.forEach(element => { | |
var a = element.querySelector("a") | |
if (a) { | |
listMovies.push(a.href) | |
} | |
}); | |
return listMovies; | |
} | |
fetch("https://www.cinecalidad.to") | |
.then(response => { | |
if (response.status === 200) { | |
return response.text(); | |
} else { | |
throw new Error('Something went wrong on api server!'); | |
} | |
}) | |
.then(response => { | |
console.log('Movies:', getDetailsMovie(response)); | |
// ... | |
}).catch(error => { | |
console.error(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment