一篇ruby寫掃描當(dāng)前網(wǎng)頁所有url的腳本獻(xiàn)給各位,對于學(xué)習(xí)ruby的朋友是個(gè)不錯(cuò)的實(shí)例呢,需要的朋友趕緊跟上武林技術(shù)小編的步伐,一來來參考下其中的內(nèi)容詳情。
#scanweb.rb
#用法ruby scanweb.rb www.5lwq4hdr.cn 將當(dāng)前結(jié)果保存在c:/1.txt
require 'net/http'
filename= File.new('c:/1.txt',"w+")
if $*[0]==nil
puts "hehe,沒有輸入網(wǎng)址"
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 ,結(jié)果放在當(dāng)前目錄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寫掃描當(dāng)前網(wǎng)頁所有url的腳本就為大家介紹到這里,如果還有其他疑問,歡迎補(bǔ)充,有任何問題也可以與武林編輯一起討論。
新聞熱點(diǎn)
疑難解答
圖片精選