Skip to content

Instantly share code, notes, and snippets.

@miyohide
Created August 14, 2011 05:50
Show Gist options
  • Save miyohide/1144626 to your computer and use it in GitHub Desktop.
Save miyohide/1144626 to your computer and use it in GitHub Desktop.
はてなダイアリーの記事一覧を取得する
#!/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