Advertisement
throwawayrobot

~/pastebin.lua

Feb 24th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. local internet = require("internet")
  2. local object = require("object")
  3. local Request = require("Request")
  4. local Parser = require("Parser")
  5.  
  6. local request = object(Request)
  7. local pastebin = object(Parser, "http://www.pastebin.com")
  8. function pastebin.user_index(html)
  9.   local file_list = {}
  10.   for line in html:between('<table class="maintable">', '</table>') do
  11.     local id, name = line:match('<a href="/(%w+)">(%g+)</a>')
  12.     table.insert(file_list, {
  13.         name = name;
  14.         url = string.format(self.url .. '/raw/%s', id)
  15.     })
  16.   end
  17.   return file_list
  18. end
  19.  
  20.  
  21. request:update(pastebin.user_index, '/u/throwawayrobot', function(files)
  22.   for n, file in files do
  23.     print(n, file.name, file.url)
  24.   end
  25. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement