btcboxの各種値をスクレイピングするスクリプト。
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
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