Created
August 14, 2011 05:50
-
-
Save miyohide/1144626 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/env ruby | |
# -*- coding: utf-8 -*- | |
require 'pit' | |
require 'wsse' | |
require 'net/http' | |
Net::HTTP.version_1_2 | |
config = Pit.get("hatena", :require => { | |
"username" => "your username", | |
"password" => "your password" }) | |
Net::HTTP.start('d.hatena.ne.jp', 80) { |http| | |
response = http.get('/' + config["username"] + '/atom/blog', | |
{'X-WSSE' => WSSE::header(config["username"], | |
config["password"])}) | |
case response | |
when Net::HTTPOK then | |
File.open("response.txt", 'w') { |f| | |
f.puts response.body | |
} | |
else | |
STDERR.puts "error..." | |
end | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment