Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I parse HTML data from a website?

Hey everyone, I recently started to learn about https and how to use it with Roblox lua. Although still pretty confused, I think I understand the basics. Looking at it in the Roblox Dev Hub, it gives an example suggesting that the website returns JSON data. Now most websites I have encountered don't do this, and instead, return HTML data.

This brings me to my main question: How would I "Parse" HTML data, or more accurately, sort HTML data into a table without a third party item?

Thanks in advance!

1 comment

1

Parsing the full HTML body might aswell be your deathwish. You need to look for web URL's that actually return JSON content. For example https://www.roblox.com returns plain HTML body. However https://api.roblox.com/users/1 returns a JSON body.

1 answer

HTML data is meant for viewing and not reading data from.. when you go to Roblox.com it returns an HTML form for your browser to display.. HTML does not have descriptive fields(properties) that you can read to get useful data.. i mean you can have an external server with an HTML parsing library, but this is not good practice.. so i recommend that you just stick to web servers that return JSON data b/c roblox has methods that you can use to parse it into a lua object(JSONEncode and JSONDecode)..

3 comments

0

How do you check if a website returns JSON data? If it does, how would you find the link that returns that data?

0

you see, when you to roblox.com/avatar, it will return the HTML for avatar display.. HTTP is usually meant for servers maintained by you, or servers that serve as APIs this way so you know what they respond with such as : http://open-notify.org/Open-Notify-API/ISS-Location-Now/

This discussion is preserved as it was. New answers, comments, and votes are closed.