Opening urls

hi could any one tell me how to open a web page in ruby i can open files
on my pc IO.popen(wmp){file location}
but cant seem to do web pages also my browser is chrome do i need i.e
instead
thanks

On Tuesday, May 18, 2010 01:47:39 pm Mark K. wrote:

hi could any one tell me how to open a web page in ruby

require ‘open-uri’
open ‘http://example.com/foo’ do |web|

end

That’s one way.

i can open files
on my pc IO.popen(wmp){file location}

I seriously doubt that this is how you open files.

but cant seem to do web pages also my browser is chrome do i need i.e
instead

No, never. Also, your browser has nothing to do with Ruby’s ability to
make
network connections.

Or is that what you’re asking? Or are you asking how to get Ruby to
point your
web browser to that location?

sorry i use IO.popen(file location here) to open files works fine i
wanted my program to open the page with a specifide command

Or is that what you’re asking? Or are you asking how to get Ruby to
point your
web browser to that location?
yes this is what i want please help me

Mark K. wrote:

Or is that what you’re asking? Or are you asking how to get Ruby to
point your
web browser to that location?
yes this is what i want please help me

There is a pretty good blog devoted to automating Windows using Ruby.
If you are using Internet Explorer you may want to check it out. The
URL is Ruby on Windows: ie. I’ve used the
information there to write Ruby scripts to automatically open Internet
Explorer and navigate to a web page. It required ‘win32ole’, which
comes standard with the Ruby windows installer.

–Alex

Alex DeCaria wrote:

Mark K. wrote:

Or is that what you’re asking? Or are you asking how to get Ruby to
point your
web browser to that location?
yes this is what i want please help me

There is a pretty good blog devoted to automating Windows using Ruby.
If you are using Internet Explorer you may want to check it out. The
URL is Ruby on Windows: ie. I’ve used the
information there to write Ruby scripts to automatically open Internet
Explorer and navigate to a web page. It required ‘win32ole’, which
comes standard with the Ruby windows installer.

–Alex

thanx ill try this

As an example, here is a program that will open internet explorer,
navigate to a flight tracker webite, and automatically refresh every 60
seconds.

–Alex

require ‘win32ole’
print "Enter Airline and Flight Number: "
flight = gets.strip
n = 60
browser = WIN32OLE.new(‘InternetExplorer.Application’)
browser.navigate(“Live Flight Tracker - FlightAware”)
browser.visible = true
loop do
sleep(n)
browser.refresh
print Time.now, “\n”
end