Skip to content

Instantly share code, notes, and snippets.

@sethkrasnianski
Last active April 6, 2017 04:27
Show Gist options
  • Save sethkrasnianski/07d8e49d32bd48aacdca7578e466dff0 to your computer and use it in GitHub Desktop.
Save sethkrasnianski/07d8e49d32bd48aacdca7578e466dff0 to your computer and use it in GitHub Desktop.
Blockbuster Locations

http://www.blockbuster.com/franchise.html

Here's the full count per state:

AK: 13
FL: 1
IN: 6
KY: 3
LA: 1
MN: 1
MS: 1
ND: 1
OR: 7
SD: 2
ST: 1
TN: 1
TX: 14

Total: 52

I quickly grabbed these values using JavaScript.

To grab an associative array of states and their location count:

Array
.from(document.querySelectorAll('table tr'))
.map((tr) => {
    if (tr.childNodes.length < 5) {
      return;
    }
    
    return tr.childNodes[5].innerText;
})
.filter(state => state !== undefined)
.reduce(function (acc, val) {
  if (typeof acc[val] === 'undefined') {
    acc[val] = 1;
  } else {
    acc[val] += 1;
  }

  return acc;
}, {});

To grab the total count:

Array
.from(document.querySelectorAll('table tr'))
.map((tr) => {
    if (tr.childNodes.length < 5) return;
    return tr.childNodes[5].innerText;
})
.filter(state => state != undefined)
.length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment