DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Use Ruby To Scrape A Url

03.20.2006
| 3430 views |
  • submit to reddit
        // description of your code here

require 'open-uri'
cmdStr1="wget http://www..... -q -O test1.html --load-cookies=cookies.txt"

# system cmdStr1
searchURI = "test1.html"
open(searchURI) do |f|
fileText=f.read
puts fileText
r1=Regexp.new('<title>(.*?)<')
uname = fileText.scan(r1)
puts [uname[0]].join(" ")
end
# end user loop