Ruby on rails 为什么不在控制台中显示一组指向Ruby资源的链接
为什么不在控制台中显示一组指向Ruby资源的链接Ruby on rails 为什么不在控制台中显示一组指向Ruby资源的链接,ruby-on-rails,ruby,uri,Ruby On Rails,Ruby,Uri,为什么不在控制台中显示一组指向Ruby资源的链接 require 'open-uri' url = 'http://www.google.com/search?q=ruby' open(url) { |page| page_content = page.read() links = page_content.scan(/<a class=1.*?href=\"(.*?)\"/).flatten links.each { |link| puts link } } 我哪里错了?您在reg
require 'open-uri'
url = 'http://www.google.com/search?q=ruby'
open(url) { |page| page_content = page.read()
links = page_content.scan(/<a class=1.*?href=\"(.*?)\"/).flatten
links.each { |link| puts link }
}
我哪里错了?您在regexp中有一个输入错误:
# ⇓
/<a class=1.*?href=\"(.*?)\"/
#⇓
/
# ⇓
/<a class=1.*?href=\"(.*?)\"/