asdaa0

Download File

Feb 14th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.47 KB | None | 0 0
  1. function download(url, file)
  2.     local content = http.get(url).readAll();
  3.  
  4.     if not content then
  5.         error("Could not connect to website");
  6.     end
  7.  
  8.     f = fs.open(file, "w");
  9.     f.write(content);
  10.     f.close();
  11. end
  12.  
  13. local args = { ... };
  14.  
  15. if #args == 0 or #args == 1 then
  16.     print("Call this script like this:");
  17.     print("SCRIPT [URL] [FILENAME]");
  18.     do return end
  19. end
  20.  
  21. if #args >= 2 then
  22.     download(args[1], args[2]);
  23.     do return end
  24. end
Add Comment
Please, Sign In to add comment