
Untitled
By: a guest on
Jun 20th, 2012 | syntax:
None | size: 0.65 KB | hits: 9 | expires: Never
tArgs = {...}
if #tArgs < 1 then
print('Usage: print_urls <url>')
return
end
url = tArgs[1]
page = http.get(url)
h = html.parsestr(page.readAll())
root = h
function search(obj)
local res = {}
if type(obj) == 'table' then
if(obj._tag and (obj._tag == 'a') ) then
if type(obj[1]) == 'string' then
table.insert(res, {obj[1], obj._attr.href})
end
else
for i,v in ipairs(obj) do
local res2 = search(v)
for j,w in ipairs(res2) do
table.insert(res, w)
end
end
end
end
return res
end
local urls = search(root)
textutils.tabulate( unpack(urls) )