Getting Things from a Website

If I put print("hi") as all the data on a website page, how in a script, can I get that from the site and run the code.

Use HTTPService - GetAsync or RequestAsync will work.

The HTTP request will be returned when you do something like:

local response = HttpService:GetAsync("example.com")

local data = HttpService:JSONDecode(response) --JSON Decode converts JSON string into a lua table

print(data.StatusCode) --Assuming a Status code is passed

To run code stored on the web app, you can use loadstring, decompile it yourself, etc. The method you choose is up to you. I do understand that loadstring makes a lot of people uncomfortable, but it can work.

11 Likes

I would use RequestAsync since it returns a table of info that could help with error handling.

1 Like

I personally prefer RequestAsync to all other methods due to its flexibility. I like how it actually reflects a real HTTP Request in which you can send headers and extra data along with a request. Not only that, but it is very flexible and allows you to use any http method even outside of get and post.

GetAsync is easier to explain to new people though as it is kind of self explanatory and simplifies things down a lot.