Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #coding:utf-8
- require "nokogiri"
- require "kconv"
- require 'json'
- Dir.chdir File.dirname __FILE__
- tmp =[]
- count=0
- open("tosken_db.txt", 'w') do |io|
- Dir["files/*.txt"].map do |file|
- s=open( file ).read.toutf8
- # p file
- p count+=1
- ["nil","material","item","recipe","monster"][1..-1].each.with_index(1) do |m,i|
- if s =~ /(a href=\".\/\?CAT=#{i}.*?\")/
- url = $1
- $1 =~ /ID=(\d*)/
- id = $1
- s[url] = "a href=\"#\" onclick=\"onButtonClick(\'#{m}\' , #{id});\""
- redo
- end
- end
- File.basename(file) =~ /(.*?)_/
- p fnum = $1
- tmp << {:id => "#{fnum}","src"=>s}
- end
- p :out
- JSON.dump(tmp, io)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement