Skip to content

Instantly share code, notes, and snippets.

@blue1st
Created April 26, 2015 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blue1st/b9b10d1f9ef99029fd0c to your computer and use it in GitHub Desktop.
Save blue1st/b9b10d1f9ef99029fd0c to your computer and use it in GitHub Desktop.
btcboxの各種値をスクレイピングするスクリプト。
phantom = require 'phantom'
cheerio = require 'cheerio'
if process.argv.length <= 2
console.log "coin type error!"
process.exit()
coin = process.argv[2]
unless coin in ['btc','ltc', 'doge']
console.log "coin type error!"
process.exit()
phantom.create (ph) ->
ph.createPage (page) ->
url="https://www.btcbox.co.jp/coin/#{coin}/"
page.open url, (status) ->
console.log "opened btcbox-#{coin}?", status
page.evaluate ( -> document.querySelector('html').innerHTML), (html) ->
$ = cheerio.load html
console.log "価格 #{$("#market-price").text()}"
console.log "高値 #{$("#market-max").text()}"
console.log "安値 #{$("#market-min").text()}"
console.log "売気配値 #{$("#market-sell").text()}"
console.log "買気配値 #{$("#market-buy").text()}"
console.log "出来高 #{$("#market-sum").text()}"
ph.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment