Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #coding:utf-8
  2. require "nokogiri"
  3. require "kconv"
  4. require 'json'
  5.  
  6. Dir.chdir File.dirname __FILE__
  7.  
  8.  
  9. tmp =[]
  10. count=0
  11. open("tosken_db.txt", 'w') do |io|
  12. Dir["files/*.txt"].map do |file|
  13. s=open( file ).read.toutf8
  14. # p file
  15. p count+=1
  16. ["nil","material","item","recipe","monster"][1..-1].each.with_index(1) do |m,i|
  17. if s =~ /(a href=\".\/\?CAT=#{i}.*?\")/
  18. url = $1
  19. $1 =~ /ID=(\d*)/
  20. id = $1
  21. s[url] = "a href=\"#\" onclick=\"onButtonClick(\'#{m}\' , #{id});\""
  22. redo
  23. end
  24. end
  25. File.basename(file) =~ /(.*?)_/
  26. p fnum = $1
  27. tmp << {:id => "#{fnum}","src"=>s}
  28. end
  29. p :out
  30. JSON.dump(tmp, io)
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement