Created
June 24, 2009 11:30
-
-
Save mccxj/135192 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
# backup from uptolife.blogspot.com | |
$KCODE='gbk' | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
gem 'activerecord','2.1.2' | |
require 'active_record' | |
require 'thread' | |
ActiveRecord::Base.establish_connection(:adapter => 'mysql', | |
:database => 'test', :host => '192.168.1.184', :username => 'root', | |
:password => '123456', :encoding => 'utf8') | |
# id,title,body,tag,post_on,link | |
class Post < ActiveRecord::Base | |
end | |
class Builder::XmlMarkup | |
def ax!(text) | |
_ensure_no_block block_given? | |
_special("", "", text, nil) | |
end | |
end | |
xm = Builder::XmlMarkup.new | |
xm.instruct! | |
xm.BlogBusCom("dtype" => "BlogDate", "SchemaVersion" => "1.1", "Creator" => "BlogBus.Com BlogSystem V4.0") do | |
xm.Description do | |
xm.BlogName do xm.ax! "鼠中无大将" end | |
xm.DomainName("uptolife.blogbus.com") | |
xm.ExportTime("2009-06-24 13:52:58") | |
end | |
Post.all(:conditions => "id >= 476", :limit => 5).each do |po| | |
xm.Log do | |
xm.Title do xm.ax! po.title end | |
xm.Status("1") | |
xm.AllowComment("Y") | |
xm.AllowPing("Y") | |
xm.AllowLinks("Y") | |
xm.Writer("") | |
xm.Sort("") | |
xm.Content do | |
xm.cdata!(po.body) | |
end | |
xm.Tags do xm.ax! po.tag end | |
xm.LogDate(po.post_on.to_s(:db) + " 08:08:08") | |
xm.Comments("") | |
end | |
end | |
end | |
open("blogbus-demo.xml",'w') do |f| | |
f.write(xm.target!) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment