Ruby Write scan current page All URLs script _ruby topic
Source: Internet
Author: User
#scanweb. RB
#用法ruby scanweb.rb www.jb51.net to save the current results in C:\1.txt
Require ' net/http '
Filename= file.new (' C:\1.txt ', "w+")
If $*[0]==nil
Puts "hehe, no input URL"
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
#无聊, there are vbs, PHP, ruby version, like Ruby faster than VBS, and PHP is comparable.
=begin
Modify
Require ' net/http '
Filename= file.new (' 1.txt ', "w+")
If $*[0]==nil
Abort "Usage Example: Ruby #$0 www.sohu.com, results in 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
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.