Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get Characters from the IMDB page for a movie (i.e.
var tableRowNodes = document.querySelectorAll('.cast_list tr')
var tableRowArray = Array.from(tableRowNodes)
var {mainCast} = tableRowArray.reduce((acc, row) => {
if (!acc.firstSkipped) {
acc.firstSkipped = true
} else if (acc.restOfCastStarted) {
} else if (row.classList.contains('odd') || row.classList.contains('even')) {
} else {
acc.restOfCastStarted = true
return acc
}, {mainCast: [], rest: []})
var characters = mainCast
.map(node => node.querySelector('.character a'))
.filter(anchor => !!anchor)
.map(anchor => anchor.textContent)
console.log('The characters have been added to your clipboard')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.