Help working with HTTP GET request responses

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.

Here is a example using https://weather.com/weather

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?

Thanks!

1 Like

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.

Also, this is off topic. But what would be the steps to getting Youtubes API? Aka a youtubers subscriber count, total videos, ect.

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.

1 Like

Thanks! This is very helpful. Btw is a dark sky API key obtained by paying?

1 Like

They offer 1,000 calls per day for free, then it’s pay as you go. Here’s the docs. https://darksky.net/dev/docs

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.

Thanks very much dude! This helps a whole lot.

2 Likes

In the future, please search for similar topics before posting. A very similar question has already been answered.

2 Likes

Ooh… Strange. I searched the topic before hand but I found no results. Sorry about that.

1 Like