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
)

chara = dqx.character

info = chara.info
info.id   #=> "TV327-610"
info.name #=> "ソプラナ"
# フレンド申請おk

house = chara.house
house.country      #=> "アズラン住宅村"
house.city         #=> "おごそかな林道地区"
house.house_number #=> "3849丁目 6番地 (Sサイズ)"
# 遊びにきておk

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