Created
October 28, 2009 13:58
-
-
Save miyucy/220498 to your computer and use it in GitHub Desktop.
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
#!/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