Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tArgs = {...}
- if tArgs[1] == nil or tArgs[2] == nil then
- print("Usage: "..shell.getRunningProgram().." <url> <name>")
- return
- end
- local check = string.sub(tArgs[1], 1, 7)
- if check == "http://" then
- tArgs[1] = string.sub(tArgs[1], 8, #tArgs[1])
- end
- http.request("http://"..tArgs[1])
- event,url,source = os.pullEvent()
- if event == "http_success" then
- local text = source.readAll()
- if fs.exists(tArgs[2]) then
- fs.delete(tArgs[2])
- end
- file = fs.open(tArgs[2], "w")
- file.write(text)
- file.close()
- elseif event == "http_failure" then
- print("Not a valid website! Or maybe your internet died..")
- end
Add Comment
Please, Sign In to add comment