parse.lua

changeset 0
0e2b5dc7ae34
child 2
5c9d6eba65bc
equal deleted inserted replaced
-1:000000000000 0:0e2b5dc7ae34
1 local http = require "socket.http"
2 local have_https, https = pcall(require,"https");
3 local csv = require "csv"
4
5 for line in io.lines("gsoc10.csv") do
6 local project = {};
7 csv.read_record(line, function (v) project[#project+1] = v; end);
8 local url = project[5]:match("https?://[^\"]+");
9 if url and url:match("^http"..(have_https and "s?" or "")..":") then
10 local data, err = http.request(url);
11 if not data then
12 print("[FAIL] "..project[2]..": "..tostring(err));
13 elseif data:match("[%W%p][Ll][Uu][Aa][%W%p]") then
14 print(project[2]..": "..url);
15 end
16 elseif project[2] ~= "Name" then
17 print("[FAIL] "..project[2]..": Couldn't fetch URL ("..(url or "couldn't find one")..")");
18 end
19 end

mercurial