-- Łódź, Bez Atu
-- Script author: Piotr Beling <qwak82@gmail.com>

local base_url = "http://bezatu.republika.pl/";

local curr_year = os.date("%Y");	--current year

for year = (curr_year-1), curr_year do	--we want years previous and current
	local content = url.download(base_url.."wyniki"..(year%100)..".html")
	if content ~= nil then	--if download something
		local content = string.gsub(content, '<!%-%-.-%-%->', '')	-- remove comments
		for name, u in string.gmatch(content, '(%d%d%.%d%d%.%d%d%d%d).-href="([^"]-)">protoko') do
			--insert deal url to results table, at first position we want to have the newest results			
			table.insert(results, 1, {["url"]=base_url..u, ["name"]=name})
		end
	end
end

