Created
February 17, 2013 04:29
-
-
Save yamashiro/4970153 to your computer and use it in GitHub Desktop.
coffeescript で AU の User Agent 情報ページから端末名をぶっこぬく
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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