Skip to content

Instantly share code, notes, and snippets.

Last active July 12, 2016 04:54
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
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