Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# -*- 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
You can’t perform that action at this time.