Lyne

スクエアエニックスが運営するドラゴンクエスト10のメンバーズサイト「冒険者の広場」をスクレイピングするgemです.

install

内部でphantomjsを使ってスクレイピングするためinstallしてください.

http://phantomjs.org/download.html

# osx
$ brew update && brew install phantomjs

use

$ gem install Lyne
gem 'lyne'

optionで渡すcharacter_idはキャラクター選択画面の「このキャラを選択」ボタンのrel属性の値になります。

character_id

require 'lyne'

dqx = Lyne::Account.new(
  account:      'account_name',
  password:     'account_password',
  character_id: 975829418411224
)

info = dqx.character.info
info.id   #=> "TV327-610"
info.name #=> "ソプラナ"

test

$ cp spec/account.yaml.example spec/account.yaml
# spec/account.yaml
account:
  name:         account_name
  password:     account_password
  character_id: 975829418411224
$ rspec spec/character/info_spec.rb