From: William James Date: 2008-03-02T00:04:57+09:00 Subject: Re: Scan HTML On Mar 1, 7:56 am, Tom Arra wrote: > Tom Arra wrote: > > William James wrote: > >> On Feb 29, 9:22 pm, Tom Arra wrote: > >>> > >>> > > >>> I want the script to return "test" > >>> -- > >>> Posted viahttp://www.ruby-forum.com/. > > >> require 'net/http' > >> puts Net::HTTP.new('www.google.com').get('/'). > >> body[ %r{(.*?)}mi, 1 ] > > >> If the tag can contain attributes, e.g., > >> : > > >> require 'net/http' > >> puts Net::HTTP.new('www.google.com').get('/'). > >> body[ %r{<title(?:\s*|\s+.*?)>(.*?)</title\s*>}mi, 1 ] > > > So far I think this is closest to what I am looking for. I need to go to > > a website that has a server information and pull that out of the HTML. > > Then take that info and spit it back out to the user. If I am > > understanding the code above, it at least does the first part which I > > had no clue how to do. > > Well I just tried it and it worked like a charm. My next thing is to > limit what it brings back. > > Example > <h3>blah blah blah 7.0.0.3.4 blah blah blah</h3> > > I want to pull just the 7.0.0.3.4 and none of the words. I am sure this > is going to have to deal with more regular expressions but I never > really understood how to use them well. > -- > Posted viahttp://www.ruby-forum.com/. E:\>irb --prompt xmp s = " <h3>blah blah 7.0.0.3.4 blah</h3>" ==>" <h3>blah blah 7.0.0.3.4 blah</h3>" # Find a substring composed of numerals and dots that is # at least 3 characters long. s[ /[\d.]{3,}/ ] ==>"7.0.0.3.4"