Tue, 03 Mar 2015 12:10:18 +0000
URL is now column 4
0 | 1 | local http = require "socket.http" |
2 | local have_https, https = pcall(require,"https"); | |
4
0dc2ccd703e3
Some packages have ssl.https...
Matthew Wild <mwild1@gmail.com>
parents:
3
diff
changeset
|
3 | if not have_https then |
0dc2ccd703e3
Some packages have ssl.https...
Matthew Wild <mwild1@gmail.com>
parents:
3
diff
changeset
|
4 | have_https, https = pcall(require,"ssl.https"); |
0dc2ccd703e3
Some packages have ssl.https...
Matthew Wild <mwild1@gmail.com>
parents:
3
diff
changeset
|
5 | end |
0 | 6 | local csv = require "csv" |
7 | ||
6 | 8 | for line in io.lines(arg[1] or "gsoc15.csv") do |
0 | 9 | local project = {}; |
10 | csv.read_record(line, function (v) project[#project+1] = v; end); | |
7 | 11 | local url = project[4] and project[4]:match("https?://[^\"]+"); |
0 | 12 | if url and url:match("^http"..(have_https and "s?" or "")..":") then |
13 | local data, err = http.request(url); | |
14 | if not data then | |
15 | print("[FAIL] "..project[2]..": "..tostring(err)); | |
16 | elseif data:match("[%W%p][Ll][Uu][Aa][%W%p]") then | |
17 | print(project[2]..": "..url); | |
18 | end | |
19 | elseif project[2] ~= "Name" then | |
20 | print("[FAIL] "..project[2]..": Couldn't fetch URL ("..(url or "couldn't find one")..")"); | |
21 | end | |
22 | end |