Skip to content

Instantly share code, notes, and snippets.

@bnoguchi
Created May 5, 2012 22:32
Show Gist options
  • Save bnoguchi/2605994 to your computer and use it in GitHub Desktop.
Save bnoguchi/2605994 to your computer and use it in GitHub Desktop.
phishApi html destructuring
destructure = (s) -> s.split("</a>").map (x) -> title: x[x.lastIndexOf('>')+1..], url: x.match(/href="([^"]+)"/)?[1]
reduceCb = (mem, curr) -> mem[curr[0...curr.indexOf ':']] = destructure curr; mem
dataBySetNumber = json.setlistdata.split(/<span[^>]+>Set /)[1..].reduce reduceCb, {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment