C
Charles Pareto
Hi,
I was reading through Learning Ruby and was trying to get the example on
page 119 to work to scrape Google. But when I run it nothing happens.
Any help would be appreciated. Thanks.
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}
}
I was reading through Learning Ruby and was trying to get the example on
page 119 to work to scrape Google. But when I run it nothing happens.
Any help would be appreciated. Thanks.
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}
}