Created
October 5, 2010 14:55
-
-
Save shokai/611679 to your computer and use it in GitHub Desktop.
hatena land
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/env ruby | |
require 'rubygems' | |
require 'mechanize' | |
require 'nokogiri' | |
require 'kconv' | |
require 'open-uri' | |
USER = 'username' | |
PASS = 'passpass' | |
@agent = Mechanize.new | |
@agent.user_agent_alias = 'Windows IE 7' | |
page = @agent.get('https://www.hatena.ne.jp/login?auto=0&backurl=http%3A%2F%2Fl.hatena.ne.jp%2F') | |
login_form = page.forms.first | |
login_form.fields_with(:name => 'name').first.value = USER | |
login_form.fields_with(:name => 'password').first.value = PASS | |
login_form.click_button | |
page = @agent.get('http://l.hatena.ne.jp/') | |
post_form = page.forms.first | |
post_form.fields_with(:name => 'body_text').first.value = 'test' | |
post_form.click_button |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment