節點精靈系列 - Lua 純原始碼取網路時間

2020-09-19 12:04:47
--Time: 202091802:15:42
-- by : MemoryChobits 
-- QQ : 1762272313
function GetMind(str,ks,over)
	local strchar=string.find(str,ks)
	if (strchar>1) then
		local bafter=string.find(str,over,strchar+string.len(ks))
		if (bafter>1) then
			local Getdata=string.sub(str,strchar+string.len(ks),bafter-1)
			print(Getdata);
			return GetData
		end
	end
	return ""
end

function GetTime()
	-- 獲取網頁的所有資料
	local p={
		url="http://www.time163.com/";
	}
	res=httpGet(p);
	if res then		
        local time = GetMind(res.body,"<header>\n<time>","</time>")
        return time ;
	else
		print("獲取失敗")
        return nil ;
	end
end

GetTime()