PKUの問題一覧を取得する

http://poj.org/moreproblemを呼び出すと,問題の一覧を取得することが出来ます

# -*- encoding: UTF-8 -*-
require 'rexml/document'
require 'open-uri'
require 'net/http'
require 'scanf'

http=Net::HTTP.new("poj.org/",80)
instr=http.post("moreproblem",'user_ids=""').body.force_encoding("UTF-8")

TMP="+source+\"</td></tr>\")\r\n}\r\ns("
id=instr.index(TMP)
instr=instr.slice(id+TMP.length(),instr.length()-id-TMP.length())
pbs=instr.split(");s(")
res=Array.new
pbs.each{|a|
        res.push([a.split(",")[0].to_i,a.slice(a.index('"')+1,a.index('"',a.index('"')+1)-a.index('"')-1)])
}
p res