Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用 ruby 脚本下载网页中的所有链接。我的想法是如果可以获得源代码,则提取 href 链接,使用命令提示符设置下载位置。有办法吗?
#!/usr/bin/env ruby # require "net/http" require "uri" #past your link gets = STDIN.gets rescue nil url = URI.parse gets http = Net::HTTP.start(url.host, url.port) do |resp| puts resp.get(url.request_uri).body end #your regular for href
或使用http://nokogiri.org/