-- Web Reader 1.0 -- --by Mutor The Ugly -- -- Grabs the code from a url and sends to: -- -- Main chat -- -- Private Message -- -- Saves As Text -- Grab just the text or full html code -- -- Usage : +wread -- ie.. +wread http://www.google.com/index.html -- -- --User Settings------------------------------------------------------------------------------------- Bot = "[WebReader]" --Name for bot Command = "+wread" --Script Command gport = 80 --Port to connect to [80 is the default for web servers PMResult = "no" --Report results in PM Save2File = "yes" --Save to text file [will save text or full code if enabled FullCode = "yes" --Show/Save all html code or just text [html tags removed ...well mostly :P] --End User Settings---------------------------------------------------------------------------------- -- function GetNews(user, data) FileName = filename if Save2File ~= "yes" then filename = "[ DISABLED ]" end local dsp dsp = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n" dsp = dsp.."\t >Fetching URL: "..ghost..gfile.."\r\n" dsp = dsp.."\t >Saving To Filename: "..filename.."\r\n" dsp = dsp.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n" user:SendData(Bot,dsp) GETHTML = "GET "..gfile.." HTTP/1.1\r\nHost: "..ghost.."\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n" local socket, err = connect(ghost, gport) local code = "" if not err then socket:timeout(2) socket:send(GETHTML..strchar(13,10)) local line = "" while not err do line, err = socket:receive("*a") code = code..line --.."\r\n"-- x = gsub(code, "^(.+)%s*> > "," <<") x = gsub(x, ""," <<") x = gsub(x, "//","") x = gsub(x, ";}","") x = gsub(x, " "," ") x = gsub(x, ""","\"") x = gsub(x, "»","»") x = gsub(x, "&","&") x = gsub(x, "<","<") x = gsub(x, ">",">") x = gsub(x, "%%20"," ") x = gsub(x, "%s%s+","") x = gsub(x, "™","™") x = gsub(x, "©","©") x = gsub(x, "®","®") x = gsub(x, "•","•") x = gsub(x, "°","°") x = gsub(x, "·","·") x = gsub(x, "","\r\n") x = gsub(x, "","\r\n") x = gsub(x, "","\t") x = gsub(x, "

","\r\n") x = gsub(x, "
","\r\n") x = gsub(x, "<([^>]-)>","") end socket:close() end socket:close() if PMResult == "yes" then user:SendPM(FileName,x) if Save2File == "yes" then SaveFile(filename,x) end if FullCode == "yes" then user:SendData("AllCode: "..FileName,"\r\n\r\n"..code) if Save2File == "yes" then SaveFile("AllCode_"..filename,code) end end else user:SendData(FileName,x) if Save2File == "yes" then SaveFile(filename,x) end if FullCode == "yes" then user:SendData("AllCode: "..FileName,"\r\n\r\n"..code) if Save2File == "yes" then SaveFile("AllCode_"..filename,code) end end end GETHTML = "" ghostin = "" ghost = "" gfile = "" end function DataArrival(user, data) if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(Bot)) == "$To: "..Bot) then data = strsub(data,1,strlen(data)-1) s,e,cmd, ghostin, gfile = strfind(data, "%s+(%S+)%shttp%:%/%/(%S+%.[^%.%/]+%.%a+)(%/%S+)")-- if (cmd == Command) then ghost = ghostin ghost = gsub(ghost, "http://","") ghost = gsub(ghost, "HTTP://","") fixhost = gsub(ghost, "%.", "-") fixfile = gsub(gfile, "/", "-") fixfile = gsub(fixfile, ".html", ".txt") fixfile = gsub(fixfile, ".htm", ".txt") fixfile = gsub(fixfile, ".php", ".txt") fixfile = gsub(fixfile, ".php?", ".txt") fixfile = gsub(fixfile, ".cgi", ".txt") fixfile = gsub(fixfile, ".asp", ".txt") fixfile = gsub(fixfile, ".cfm", ".txt") filename = fixhost..fixfile GetNews(user, data) return 1 end end end function SaveFile(filename,code) local handle = openfile(filename,"w") write(handle,code) closefile(handle) end