I need to get the time to print once from a website, but all I have is this. I'm new to HTTPService; need some guidance.
hs = game:GetService("HttpService") test = hs:GetAsync("http://time.is/New_York", true)
For the sake of solving this problem, I will answer your question. But you need to know that if you want to get the current time, you should use os.time or tick
To start, know that using the GetAsync
function will return you the entire website's HTML markup. That being said, you must know what to look for in that mess of a string.
I've taken a look at the site you're trying to retrieve the time from. As you can see here, the div that holds the time has an id tag of "twd".
Now that you know what to look for, you can use the string.gmatch function to pick out your time. To do this, you need to use some string patterns:
local hs = game:GetService("HttpService") --HttpService local test = hs:GetAsync("http://time.is/New_York", true) --Web info local pattern = [[<div id="twd">........]] --Pattern to capture time for i in test:gmatch(pattern) do --'>' is the div's ending, '.+' gets everything after local capture = i:gmatch(">.+") --gmatch is an iterator function, you have to call it again. capture = capture(); --'capture' is inclusive of the div's ending -- so get everything after the first character. print(capture:sub(2)) end