Jump to content




[HTTP] Table: Help?


  • You cannot reply to this topic
2 replies to this topic

#1 Mendax

  • Members
  • 366 posts

Posted 28 May 2012 - 08:08 PM

So, I made a really nooby test code to try and work out how to use HTTP.
input = read()
print(http.get(input))
And all it comes up with is a message saying 'table:' and a bunch of numbers & letters.
Help?

#2 Pinkishu

  • Members
  • 484 posts

Posted 28 May 2012 - 08:11 PM

It has some methods like .readAll() which returns a string of the whole response and such

you coul try
for k,v in pairs(http.get(input)) do
  print(k.."=>"..v)
end
to get a method list i think

#3 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 28 May 2012 - 08:22 PM

http.get returns a handle to a (temporary) file containing the received text (the page's code normally).
To print all it's contents you can use:
local h = http.get("url")
if h then
  local s = h.readAll()
  h.close() -- not sure if really needed, but just in case
  print(s)
else
  print("Error connecting to url")
end






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users