Guest User

Untitled

a guest
Apr 12th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. # backup from uptolife.blogspot.com
  2. $KCODE='gbk'
  3. require 'rubygems'
  4. require 'nokogiri'
  5. require 'open-uri'
  6. gem 'activerecord','2.1.2'
  7. require 'active_record'
  8. require 'thread'
  9.  
  10. ActiveRecord::Base.establish_connection(:adapter => 'mysql',
  11. :database => 'test', :host => '192.168.1.184', :username => 'root',
  12. :password => '123456', :encoding => 'utf8')
  13.  
  14. # id,title,body,tag,post_on,link
  15. class Post < ActiveRecord::Base
  16. end
  17.  
  18. class Builder::XmlMarkup
  19. def ax!(text)
  20. _ensure_no_block block_given?
  21. _special("", "", text, nil)
  22. end
  23. end
  24.  
  25. xm = Builder::XmlMarkup.new
  26. xm.instruct!
  27. xm.BlogBusCom("dtype" => "BlogDate", "SchemaVersion" => "1.1", "Creator" => "BlogBus.Com BlogSystem V4.0") do
  28. xm.Description do
  29. xm.BlogName do xm.ax! "鼠中无大将" end
  30. xm.DomainName("uptolife.blogbus.com")
  31. xm.ExportTime("2009-06-24 13:52:58")
  32. end
  33. Post.all(:conditions => "id >= 476", :limit => 5).each do |po|
  34. xm.Log do
  35. xm.Title do xm.ax! po.title end
  36. xm.Status("1")
  37. xm.AllowComment("Y")
  38. xm.AllowPing("Y")
  39. xm.AllowLinks("Y")
  40. xm.Writer("")
  41. xm.Sort("")
  42. xm.Content do
  43. xm.cdata!(po.body)
  44. end
  45. xm.Tags do xm.ax! po.tag end
  46. xm.LogDate(po.post_on.to_s(:db) + " 08:08:08")
  47. xm.Comments("")
  48. end
  49. end
  50. end
  51.  
  52. open("blogbus-demo.xml",'w') do |f|
  53. f.write(xm.target!)
  54. end
Add Comment
Please, Sign In to add comment