Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get( sUrl )
- write( "Connecting to " .. sUrl .. "... " )
- local ok, err = http.checkURL( sUrl )
- if not ok then
- print( "Failed." )
- if err then
- printError( err )
- end
- return nil
- end
- local response = http.get( sUrl , nil , true )
- if not response then
- print( "Failed." )
- return nil
- end
- print( "Success." )
- local sResponse = response.readAll()
- response.close()
- return sResponse
- end
- function download( sURL,sFile ) -- Download file
- local sUrl = sURL -- Alias
- local sPath = shell.resolve( sFile )
- if fs.exists( sPath ) then
- print( "File already exists" )
- return
- end
- -- Do the get
- local res = get( sUrl )
- if res then
- local file = fs.open( sPath, "wb" )
- file.write( res )
- file.close()
- print( "Downloaded as "..sFile )
- end
- end
- download("https://raw.githubusercontent.com/msva/lua-htmlparser/master/src/htmlparser.lua","htmlparser.lua")
- fs.makeDir("htmlparser")
- download("https://raw.githubusercontent.com/msva/lua-htmlparser/master/src/htmlparser/voidelements.lua","htmlparser/voidelements.lua")
- download("https://raw.githubusercontent.com/msva/lua-htmlparser/master/src/htmlparser/ElementNode.lua","htmlparser/ElementNode.lua")
- print("Done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement