Let's say I have this:
[lua]
http.Fetch( "http://www.wikipedia.org/",
function( body ) print(body) end,
function( error ) print(error) end
)
[/lua]
It will output this giant string of the page's source.
How can I turn this into a manageable table/json that I can use?
This website: [url]http://json.fastfrag.org/[/url] does exactly what I'm talking about.
Garry's Mod doesn't contain any Lua features that could be used to parse HTML into DOM tree. Also note that not all pages out there are valid and many of them couldn't be 'converted' into a JSON structure like that.
Either use string.find to extract the information you require, or spawn a HTML panel and run some JavaScript in the window (you can traverse the document tree with JS).
A lot of sites do have an API that supports JSON though. What are you trying to do?
[url=http://www.mediawiki.org/wiki/API:Data_formats]Wikipedia API[/url]
You could probably host your own website with fastfrag on it and have it accept post info.
Sorry, you need to Log In to post a reply to this thread.