ã¯ã¦ãªãã¤ã¢ãªã¼ã®ãã¼ã¿ãå®æçã«ããã¯ã¢ãããã
diary_backup/backup.rb
#!/usr/bin/env ruby require "rubygems" require "mechanize" require "yaml" config = YAML.load_file("config.yaml") USER_NAME = config["username"] PASSWORD = config["password"] DIR = config["dir"] agent = WWW::Mechanize.new agent.post("https://www.hatena.ne.jp/login", {"name" => USER_NAME, "password" => PASSWORD, "persistent" => 1}) unless File.exist?(DIR) Dir.mkdir(DIR) end agent.get("http://d.hatena.ne.jp/#{ USER_NAME }/export").save_as("#{ DIR }/#{ USER_NAME }-#{ Time.now.strftime("%Y-%m-%d:%H:%M:%S") }.xml")
diary_backup/config.yaml
username: javascripter password: ***** dir: data
diary_backup/dataãä½ã£ã¦ããã¨ã¯crontabçã§ä¸æ¥ãã¨ã«ãã¼ã¿ããã¦ã³ãã¼ãããã