一篇ruby寫掃描當前網頁所有url的腳本獻給各位,對于學習ruby的朋友是個不錯的實例呢,需要的朋友趕緊跟上武林技術小編的步伐,一來來參考下其中的內容詳情。
#scanweb.rb
#用法ruby scanweb.rb www.companysz.com 將當前結果保存在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(/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(/puts x
filename.puts x
end
end
=end
ruby寫掃描當前網頁所有url的腳本就為大家介紹到這里,如果還有其他疑問,歡迎補充,有任何問題也可以與武林編輯一起討論。
新聞熱點
疑難解答
圖片精選