You can write your topic however you want, but you need to answer these questions:
Hi everyone! I was messing around with httpservice and had one big question.
Lets say I want to create a script that can check the temperature in certain areas.
I can do this to return the HTML block to my script, which is legit a 700 line long string of HTML.
local http = game:GetService(“HttpService”)
local Zip = “74684” – This isn’t a real zip code it’s just for the example
local url = “https://weather.com/weather/today/l/”
local ReturningHTML = http:GetAsync(url … http:UrlEncode(Zip), false)
print(ReturningHTML)
I can do everything up to this point, but now what would I do to get the actual tempature value?
Right now I’m just stuck with this monstrous code heap and not sure what to do with it.
Anyone know the solution to getting the actual info that I need from the page?
Scraping data from the web page wouldn’t really work that well. Using an API designed for this would work much better. Unfortunately, IBM sells weather data for a really expensive price. You could use Dark Sky’s weather API instead.
Ok. If I were to get the API data instead, how would I capture that?
I’m very new to the HttpService, so I’m not really sure how I would go about turn even the simplest API into individual variables containing key data. Just out of curiosity.
Here’s a little script. Not sure if it works since I’m on mobile.
local res = HttpService:GetAsync(“https://api.darksky.net/forecast/[key]/[latitude],[longitude]”)
local resObject = HttpService:JSONDecode(res)
local temp = resObject.currently.temperature
print(temp)
I didn’t add the variable for HttpService cause I’m on mobile, but something like that should work. You’d need to replace stuff like [key] with your Dark Sky key.
Your only issue might be attribution since you can’t link to 3rd party sites. You might be able to contact them and figure out a different way to give credit though.