Skip to content

Instantly share code, notes, and snippets.

@miyucy
Created October 28, 2009 13:58
Show Gist options
  • Save miyucy/220498 to your computer and use it in GitHub Desktop.
Save miyucy/220498 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby -wKU
# -*- coding: utf-8 -*-
require 'rubygems'
require 'mechanize'
require 'logger'
isbns = DATA.readlines
isbns = isbns.map{ |isbn| isbn.chomp }
agent = WWW::Mechanize.new{ |a| a.log = Logger.new('input.log'); a.user_agent_alias = 'Mac Safari' }
agent.get("http://booklog.jp/login"){ |page|
home_page = page.form_with(:name => 'frm'){ |login|
login.account = "fistfvck"
login.password = ""
}.submit
entry_page = home_page.links.find{ |l| l.href == "/entry" }.click
input_page = entry_page.links.find{ |l| l.href == '/input' }.click
# 入力フォーム
while not isbns.empty?
isbn = isbns.slice!(0,10)
input = input_page.forms.find{ |l| l.action == 'http://booklog.jp/input' }
input.method = "POST"
input.isbns = isbn.join("\r\n")
results = input.submit
input_page = results
end
}
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment