I have the following:
titles = []
url = []
titles.each do |link|
if link[:href] =~ 'http://www.google.com'
url.push(link[:href])
end
end
But I keep getting a TypeError:
TypeError: type mismatch: String given
P.S. I am trying to use Nokogiri to parse the links returned from a particular URL. If anyone has any links, aside from the Nokogiri tutorial/wiki, about how to best do that, please let me know.
The
=~operator is used for matching Regexp, not strings.http://ruby-doc.org/core-1.9.3/String.html#method-i-3D-7E
This would work, assuming you want to check if
http://www.google.comis included in the string :