This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Ch1ck3nL1v3r's profile picture

Pastebin -> variable

Started by Ch1ck3nL1v3r, 31 October 2012 - 06:54 PM
Ch1ck3nL1v3r #1
Posted 31 October 2012 - 07:54 PM
Quite simply, i want my script to take what is on a pastebin page, and save it as a variable. I haven't found any way of doing it yet, although i am sure it is staring me in the face.
remiX #2
Posted 31 October 2012 - 08:11 PM
Go through the pastebin file and look :P/>/> you use something like this


    local response = http.get(
        "http://pastebin.com/raw.php?i="..textutils.urlEncode( sCode )  -- to get the code
        )
        
    if response then
        print( "Success." )
        
        local sResponse = response.readAll()
        response.close()
        
        local file = fs.open( sPath, "w" )
        file.write( sResponse )
        file.close()
        
        print( "Downloaded as "..sFile )
        
    else
        print( "Failed." )  -- This means the url does not exist.
    end   

Thats from the pastebin file.
Ch1ck3nL1v3r #3
Posted 31 October 2012 - 08:29 PM
ah, thanks, i was missing off the whole url encoding bit, derp.
remiX #4
Posted 31 October 2012 - 08:31 PM
ah, thanks, i was missing off the whole url encoding bit, derp.

Thats kinda the main part you need :P/>/>
Ch1ck3nL1v3r #5
Posted 31 October 2012 - 08:40 PM
erm, yeah, totaly new to the HTML api, i haven't needed it until a relatively exciting new project has needed it.
remiX #6
Posted 31 October 2012 - 08:46 PM
erm, yeah, totaly new to the HTML api, i haven't needed it until a relatively exciting new project has needed it.

Haha :P/>/> It's really awesome… but make sure your http api is enabled.