#!/usr/local/bin/ruby require "socket" def usage print "showhtml by K.I -- 040527\n" print " Usage: showhtml url\n" print " Ex. showhtml http://snoopy/index.html\n" exit end $url = [] def get_args count = 0 $mode = "html" while item = ARGV.shift case item when /^-dummy1$/ $para1 = ARGV.shift when /^-body$/ $mode = "body" else count = count+1 $url.push(item) end end if count==0 usage end return count end #main get_args $url.each do |uuu| if uuu =~ /http:\/\/([\w\.]+)\/(.+)?/ s = TCPSocket.new($1,80) s.write "GET /#{$2} HTTP/1.0\r\n\r\n" line = s.read if $mode =~ /html/ && line =~ /.+<\/HTML>/mi print $& end if $mode =~ /body/ && line =~ /(.+)<\/BODY>/mi print $1 end end end