This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Logic Machine Communication - HTTP
#1
Star 
Hello, I would like to know, how can I take information from an HTTP page from the logic machine? Big Grin
Reply
#2
http://w3.impa.br/~diego/software/luasoc...ml#request
Reply
#3
Hi,

If you just need a simple datafield you can also use:

Code:
123456789101112131415161718192021
require('socket.http') socket.http.TIMEOUT = 5 -- Get data from website local data = socket.http.request('http://openrb.com') -- Check if data is received if not data then     log('No data found')     return end -- Find your data for i in string.gmatch(data, '<body>.-</body>') do     if i ~= nil then         searched_data = i:match([[<h2>(.-)</h2>]])         if i ~= nil then             log(searched_data)         end     end end
BR,

Erwin
Reply
#4
Hi, Erwin van der Zwar:
Thanks for your help. Yes, it is a simple data capture, use your code but it is not registering anything to me.
Reply
#5
Hi,

The data is now fetched between <h2> </h2> fields but i don't know the fields in your html mark-up so you have to check that and change it to those..

log(data) to see your complete reply from your url source.. or right click your source in the browser and select 'view source code' to see the structure of the site you read..

BR,

Erwin
Reply
#6
Check is gateway and DNS are set in network config.
Reply
#7
Hi,

I adjusted the sample to a (tested) version to fetch all the main topics from this forum

Code:
12345678910111213141516171819202122232425
require('socket.http') socket.http.TIMEOUT = 5 -- Get data from website local data = socket.http.request('http://forum.logicmachine.net') -- Check if data is received if not data then   log('No data found')   return end -- Find your data for i in string.gmatch(data, '<body>.-</body>') do   if i ~= nil then      for j in string.gmatch(i, '<a href="forumdisplay.-</a>') do         if j ~= nil then            searched_data = j:match([[">(.-)</a>]])            if searched_data ~= nil then               log(searched_data)            end         end      end   end end

BR,

Erwin
Reply
#8
It works, thanks for your help. Big Grin
Reply


Forum Jump: