Guest User

Untitled

a guest
Sep 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. puts "id,date,name,url,file,status,position,sort_id,pv,top"
  4.  
  5. count = 1
  6. whole = 1662
  7.  
  8. while line = gets
  9. if line.match(/href/)
  10. name = line.sub(/.*>(.*)<\/a.*/, "\\1").chomp
  11. if name.match(/[0-9]+\/[0-9]+:/)
  12. name = name[name.index(":")+1..name.length].gsub('"', '”')
  13. end
  14. date = line.sub(/.*name="([^"]+)".*/, "\\1").chomp
  15. target = line.sub(/.*href="([^"]+)".*/, "\\1").chomp
  16. if target.match(/^http/)
  17. target += ","
  18. else
  19. target = "," + target.sub(/comweb/, "old_files")
  20. end
  21. puts "#{count},#{date},#{name},#{target},2,#{whole - count},1,0,#{count <= 10 ? 1 : 0}"
  22. count += 1
  23. end
  24. end
  25. ---
  26. #!/usr/bin/ruby
  27.  
  28. puts "id,name,url,file,description,sort_id,pv,code,user,section,email,flag,created_at"
  29.  
  30. count = 1
  31. date = ""
  32. while line = gets
  33. if line.match(/href/)
  34. name = line.sub(/.*>(.*)<\/A.*/, "\\1").chomp
  35. if line.match(/^\[/)
  36. date = "2012/" + line.sub(/.*nbsp;([0-9]+) 月([0-9]+) 日.*/, "\\1/\\2").chomp
  37. elsif name.match(/[0-9]+\/[0-9]+: /)
  38. date = "2012/" + name[0..4]
  39. name = name[7..name.length]
  40. end
  41. target = line.sub(/.*href="([^"]+)".*/, "\\1").chomp
  42. if target.match(/^http/)
  43. target += ","
  44. else
  45. target = "," + target.sub(/comweb/, "old_files")
  46. end
  47. puts "#{count},#{name},#{target},,1,0,,旧データ,旧データ,admin_console,0,#{date}"
  48. count += 1
  49. end
  50. end
Add Comment
Please, Sign In to add comment