Jump to content




Pastebin -> variable


  • You cannot reply to this topic
5 replies to this topic

#1 Ch1ck3nL1v3r

  • Members
  • 18 posts

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.

#2 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

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.

#3 Ch1ck3nL1v3r

  • Members
  • 18 posts

Posted 31 October 2012 - 08:29 PM

ah, thanks, i was missing off the whole url encoding bit, derp.

#4 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 31 October 2012 - 08:31 PM

View PostCh1ck3nL1v3r, on 31 October 2012 - 08:29 PM, said:

ah, thanks, i was missing off the whole url encoding bit, derp.

Thats kinda the main part you need :P/>

#5 Ch1ck3nL1v3r

  • Members
  • 18 posts

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.

#6 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 31 October 2012 - 08:46 PM

View PostCh1ck3nL1v3r, on 31 October 2012 - 08:40 PM, said:

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.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users