95 posts
Location
Somewhere near the local computer store?
Posted 22 November 2012 - 07:00 AM
Hello,
I tried this but it says ""… Well acctually it says nothing. But heres the code:
--This is an api BTW --
function downloadFiles(sUrl)
local file = http.get("http://pastebin.com/raw.php?i="..sUrl)
local hFile = io.open("WebData", "w")
hFile:write(file)
hFile:close()
end
I've also tried this:
function downloadFiles(sUrl)
fs.delete("WebData")
shell.run("pastebin", "get", sUrl, "WebData")
end
Please help! THANKS!!!
3790 posts
Location
Lincoln, Nebraska
Posted 22 November 2012 - 07:13 AM
You forgot to read from the website.
function downloadFiles(sUrl)
local file = http.get("http://pastebin.com/raw.php?i="..sUrl)
local siteFile = file.readAll() --just need to read the website
file.close()
local hFile = io.open("WebData", "w")
hFile:write(siteFile)
hFile:close()
end
95 posts
Location
Somewhere near the local computer store?
Posted 22 November 2012 - 07:17 AM
Thank you soooo much cranuim. And derp on my part. +1
24 posts
Location
In a turtle.
Posted 22 November 2012 - 09:21 PM
I would add a save location too. Just incase you want it, here.
function downloadFiles(sUrl, sFile)
local file = http.get("http://pastebin.com/raw.php?i="..sUrl)
local siteFile = file.readAll() --just need to read the website
file.close()
local hFile = io.open(sFile, "w")
hFile:write("--Downloaded by snoble2022's pastebin function.")
hFile:write(siteFile)
hFile:close()
end
Pretty sure that will work. You might need or not need the, separating the 2 parameters in
function downloadFiles(sUrl, sFile)
278 posts
Posted 22 November 2012 - 09:25 PM
I would add a save location too. Just incase you want it, here.
function downloadFiles(sUrl, sFile)
local file = http.get("http://pastebin.com/raw.php?i="..sUrl)
local siteFile = file.readAll() --just need to read the website
file.close()
local hFile = io.open(sFile, "w")
hFile:write("--Downloaded by snoble2022's pastebin function.")
hFile:write(siteFile)
hFile:close()
end
Pretty sure that will work. You might need or not need the, separating the 2 parameters in
function downloadFiles(sUrl, sFile)
This will work, and yes you do need the comma.
24 posts
Location
In a turtle.
Posted 22 November 2012 - 09:29 PM
Just as I suspected, damn brain, tut tut tut.