minimite

download

Sep 18th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. tArgs = {...}
  2. if tArgs[1] == nil or tArgs[2] == nil then
  3. print("Usage: "..shell.getRunningProgram().." <url> <name>")
  4. return
  5. end
  6.  
  7. local check = string.sub(tArgs[1], 1, 7)
  8. if check == "http://" then
  9. tArgs[1] = string.sub(tArgs[1], 8, #tArgs[1])
  10. end
  11.  
  12. http.request("http://"..tArgs[1])
  13. event,url,source = os.pullEvent()
  14. if event == "http_success" then
  15. local text = source.readAll()
  16. if fs.exists(tArgs[2]) then
  17. fs.delete(tArgs[2])
  18. end
  19. file = fs.open(tArgs[2], "w")
  20. file.write(text)
  21. file.close()
  22. elseif event == "http_failure" then
  23. print("Not a valid website! Or maybe your internet died..")
  24. end
Add Comment
Please, Sign In to add comment