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
Uri Reader
// reads and extracts regexp using open-uri
require "open-uri"; include OpenURI
alpha=('a'..'z').to_a
snames=File.new('stations.txt','w')
alpha.each {|a|
open("http://www.irishrail.ie/your_journey/stationpicker.asp?id=#{a}&box=From") {|f|
f.each_line {|line| snames.puts line}
}}
snames=File.new('stations.txt','r')
data=snames.read
rx1=/sendValue\('([a-zA-Z]+)/
sarr=data.scan(rx1)
stations=sarr.collect{|s| s[0]}
stations.uniq!
puts stations





