http.Fetch help

Hello. I want to know how to get a number from an url. For example, stock price from Google Finance. Thinks i tried:

  1. Finding code what placed near stock price in HTML

http.Fetch("https://www.google.com/finance?cid=694653", function( body, len, headers, code )
		print(string.find(body,[[<span id="ref_694653_1" class="unchanged">]]))
	end,
	function( error )
	end)

Returns nil
2. Finding actual price of stock


http.Fetch("https://www.google.com/finance?cid=694653", function( body, len, headers, code )
		print(string.find(body,[[1,128]]))
	end,
	function( error )
	end)

Returns two numbers, but i dunno how to get there.
2.1 Tried to use string.Left and string.Right


http.Fetch("https://www.google.com/finance?cid=694653", function( body, len, headers, code )
		print(string.Left(body, string.Explode(" ", string.find(body,[[1,128]]))[1]))
	end,
	function( error )
	end)

Returns 200
EDIT
Now returns nil
EDIT AGAIN
Now returns htim like print(body)
3. Tried to print all HTML with code and then finding price by myself.


http.Fetch("https://www.google.com/finance?cid=694653", function( body, len, headers, code )
		print(body)
	end,
	function( error )
	end)

Returns not full html cause of print limit.

You’ll need some google finance api to get used.

Google Finance API is not aviable for now as I know.

[lua]
local id = “GOOG”
local URL = “http://finance.google.com/finance/info?client=ig&q=NASDAQ:” … id

http.Fetch( URL, function( html, len , headers )

local Table = util.JSONToTable( string.gsub( html, "/", "" ))[1]
PrintTable( Table )

end, function( err )
print( "Error: ", err )
end)
[/lua]

There’s probably cleaner ways. But that should work for this example. For others that don’t have any sort of API you will want to check out how to use pattern matching.

Thx a lot. Works fine. But im not so far for stocks. What variable from table i should take for price. Tried el_fix. Sometimes returns nil.
EDIT
Ah it just were bad IDs. Now everything works fine. Thanks.