ruby写扫描当前网页所有url的脚本
#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
相关推荐
PMJ0 2020-10-13
longzhiwen 2020-09-06
yangxingstar 2020-08-31
LUCIEN0 2020-08-17
huangzihao00 2020-08-17
Jan 2020-08-17
AndesStay 2020-06-12
afengxg 2020-06-09
zamesking 2020-06-09
afengxg 2020-06-09
何志文 2020-06-09
teresalxm 2020-06-05
何志文 2020-05-16
何志文 2020-05-11
fsl 2020-05-04
JOO 2020-04-26
倩 2020-04-22
afanti 2020-04-19
始终不够 2020-04-10