Skip to content

Instantly share code, notes, and snippets.

@yamashiro
Created February 17, 2013 04:29
Show Gist options
  • Save yamashiro/4970153 to your computer and use it in GitHub Desktop.
Save yamashiro/4970153 to your computer and use it in GitHub Desktop.
coffeescript で AU の User Agent 情報ページから端末名をぶっこぬく
#!/usr/bin/env coffee
console = require 'console'
#npm install jsdom
jsdom = require 'jsdom'
Array::unique = ->
output = {}
output[@[key]] = @[key] for key in [0...@length]
value for key, value of output
jsdom.env
html: 'http://www.au.kddi.com/developer/android/kishu/ua/'
scripts: 'http://code.jquery.com/jquery.js'
done: (errors, window) ->
$ = window.$
devices = []
tds = $('td')
for td in tds
match = /; (\S+?) Build/.exec $(td).text()
if match
devices.push match[1]
devices = devices.unique()
for ua in devices
console.log ua
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment