Search for web page content

How to search for a webpage in ruby ​​It's hard to explain, but here is the code for this in Python

import urllib2, re word = "How to ask" source = urllib2.urlopen("http://stackoverflow.com").read() if re.search(word,source): print "Found it "+word 
0
source share
2 answers

Directly port your code:

 require 'net/http' word = 'How to ask' source = Net::HTTP.get(URI.parse('http://stackoverflow.com/')) if source.match(word) puts "Found #{word}" end 

If you want to do something like redirects, you need to read the documentation .

+2
source

A quick look at Google gave me the following: http://snippets.dzone.com/posts/show/2430

0
source

All Articles