#scanweb.rb
#用法ruby scanweb.rb www.jb51.net 将当前结果保存在c:\1.txt
require 'net/http'
filename= File.new('c:\1.txt',"w+")
if $*[0]==nil
puts "hehe,没有输入网址"
else
h = Net::HTTP.new($*[0], 80)
resp, data = h.get('/index.html', nil)
if resp.message == "OK"
data.scan(/<a href="(.*?)"/).each do |x|
puts x
filename.puts x
end
end
end
#无聊,有vbs、php、ruby版了,好像ruby比vbs快,与php不相上下。
=begin
修改一下
require 'net/http'
filename= File.new('1.txt',"w+")
if $*[0]==nil
abort "用法示例:ruby #$0 www.sohu.com ,结果放在当前目录1.txt"
end
h = Net::HTTP.new($*[0], 80)
resp, data = h.get('/index.html', nil)
if resp.message == "OK"
data.scan(/<a href="(.*?)"/).each do |x|
puts x
filename.puts x
end
end
=end
#用法ruby scanweb.rb www.jb51.net 将当前结果保存在c:\1.txt
require 'net/http'
filename= File.new('c:\1.txt',"w+")
if $*[0]==nil
puts "hehe,没有输入网址"
else
h = Net::HTTP.new($*[0], 80)
resp, data = h.get('/index.html', nil)
if resp.message == "OK"
data.scan(/<a href="(.*?)"/).each do |x|
puts x
filename.puts x
end
end
end
#无聊,有vbs、php、ruby版了,好像ruby比vbs快,与php不相上下。
=begin
修改一下
require 'net/http'
filename= File.new('1.txt',"w+")
if $*[0]==nil
abort "用法示例:ruby #$0 www.sohu.com ,结果放在当前目录1.txt"
end
h = Net::HTTP.new($*[0], 80)
resp, data = h.get('/index.html', nil)
if resp.message == "OK"
data.scan(/<a href="(.*?)"/).each do |x|
puts x
filename.puts x
end
end
=end