# Scanweb. rb
# Use ruby scanweb. rb www.jb51.net to save the current result in c: \ 1.txt
Require 'net/http'
Filename = File. new ('C: \ 1.txt ', "w + ")
If $ * [0] = nil
Puts "hehe, no URL entered"
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
# Bored: There are vbs, php, and ruby versions. It seems that ruby is faster than vbs and comparable to php.
= Begin
Modify
Require 'net/http'
Filename = File.new('1.txt ', "w + ")
If $ * [0] = nil
Abort "usage example: ruby #$0 www.sohu.com, set the result to the current directory 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