2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
14
Task/Web-scraping/Lua/web-scraping.lua
Normal file
14
Task/Web-scraping/Lua/web-scraping.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local http = require("socket.http") -- Debian package is 'lua-socket'
|
||||
|
||||
function scrapeTime (pageAddress, timeZone)
|
||||
local page = http.request(pageAddress)
|
||||
if not page then return "Cannot connect" end
|
||||
for line in page:gmatch("[^<BR>]*") do
|
||||
if line:match(timeZone) then
|
||||
return line:match("%d+:%d+:%d+")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local url = "http://tycho.usno.navy.mil/cgi-bin/timer.pl"
|
||||
print(scrapeTime(url, "UTC"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue