require 'open-uri'
require 'rexml/document'

module RosettaCode

  URL_ROOT = 

  def self.get_url(page, query)
    begin
      
      pstr = URI.encode_www_form_component(page)
      qstr = URI.encode_www_form(query)
    rescue NoMethodError
      require 'cgi'
      pstr = CGI.escape(page)
      qstr = query.map {|k,v|
         % [CGI.escape(k.to_s), CGI.escape(v.to_s)]}.join()
    end
    url = 
    p url if $DEBUG
    url
  end

  def self.get_api_url(query)
    get_url , query
  end

  def self.category_members(category)
    query = {
       => ,
       => ,
       => ,
       => ,
       => 500,
    }
    while true
      url = get_api_url query
      doc = REXML::Document.new open(url)

      REXML::XPath.each(doc, ) do |task|
        yield task.attribute().value
      end

      continue = REXML::XPath.first(doc, )
      break if continue.nil?
      cm = REXML::XPath.first(continue, )
      query[] = cm.attribute().value
    end
  end

end