Advertisement
guitarplayer616

HTMLua

Jun 3rd, 2015
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. local tArgs = {...}
  2. local h = fs.open(tArgs[1],"r")
  3. local html = h.readAll()
  4. h.close()
  5.  
  6. local headers = {}
  7. local bodies = {}
  8. local both = {}
  9. html:gsub("<(.-)>",function(a) table.insert(headers,a) end)
  10. html:gsub(">(.-)<",function(a) table.insert(bodies,a) end)
  11.  
  12. for _,i in ipairs(headers) do
  13.   for _,v in ipairs(bodies) do
  14.     both[i]=v
  15.   end
  16. end
  17.  
  18. print(#headers)
  19.  
  20. for i=1,#headers do
  21.   if headers[i] == "h1" then term.setTextColor("blue")
  22.     print(bodies[i])
  23.   end
  24.   if headers[i] == "p" then term.setTextColor("green")
  25.     print(bodies[i])
  26.   end
  27. end
  28.  
  29.  
  30. --[[for i,v in pairs(both) do
  31.   write(i.." "..v)
  32. end]]--
  33. --print(body)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement