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
# -*- coding: utf-8 -*- | |
require 'mechanize' | |
require 'uri' | |
class DokushoMeter | |
def initialize | |
@agent = WWW::Mechanize.new | |
@agent.user_agent_alias = 'Windows IE 7' | |
end | |
def login id, password | |
@agent = WWW::Mechanize.new | |
@agent.user_agent_alias = 'Windows IE 7' | |
page = @agent.get('http://book.akahoshitakuya.com/login') | |
page.forms[1].fields_with(:name => 'mail').first.value = id | |
page.forms[1].fields_with(:name => 'password').first.value = password | |
page.forms[1].click_button | |
end | |
def import books | |
books.each do |book| | |
@agent.get("http://book.akahoshitakuya.com/add.php?asin=#{book[:isbn10]}&title=#{URI.encode book[:name]}") | |
sleep 1 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment