# Opening urls

**URL:** <https://www.ruby-forum.com/t/opening-urls/188813>\
**Category:** Ruby\
**Created:** [May 18, 2010, 8:47pm UTC](https://www.ruby-forum.com/t/opening-urls/188813 "2010-05-18T20:47:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![site-master](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/13edae/32.png) [@site-master](https://www.ruby-forum.com/u/site-master)\
**Post date:** [May 18, 2010, 8:47pm UTC](https://www.ruby-forum.com/t/opening-urls/188813/1 "2010-05-18T20:47:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![site-master](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/13edae/32.png) [@site-master](https://www.ruby-forum.com/u/site-master)\
**Post date:** [May 18, 2010, 9:19pm UTC](https://www.ruby-forum.com/t/opening-urls/188813/2 "2010-05-18T21:19:01Z")

</div>

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](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?

---

<div class="post-metadata">

**Author:** ![site-master](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/13edae/32.png) [@site-master](https://www.ruby-forum.com/u/site-master)\
**Post date:** [May 18, 2010, 9:22pm UTC](https://www.ruby-forum.com/t/opening-urls/188813/3 "2010-05-18T21:22:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![site-master](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/13edae/32.png) [@site-master](https://www.ruby-forum.com/u/site-master)\
**Post date:** [May 18, 2010, 9:56pm UTC](https://www.ruby-forum.com/t/opening-urls/188813/4 "2010-05-18T21:56:51Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![site-master](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/13edae/32.png) [@site-master](https://www.ruby-forum.com/u/site-master)\
**Post date:** [May 18, 2010, 10:29pm UTC](https://www.ruby-forum.com/t/opening-urls/188813/5 "2010-05-18T22:29:47Z")

</div>

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](http://rubyonwindows.blogspot.com/search/label/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

---

<div class="post-metadata">

**Author:** ![site-master](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/13edae/32.png) [@site-master](https://www.ruby-forum.com/u/site-master)\
**Post date:** [May 18, 2010, 10:31pm UTC](https://www.ruby-forum.com/t/opening-urls/188813/6 "2010-05-18T22:31:49Z")

</div>

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](http://rubyonwindows.blogspot.com/search/label/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

---

<div class="post-metadata">

**Author:** ![site-master](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/13edae/32.png) [@site-master](https://www.ruby-forum.com/u/site-master)\
**Post date:** [May 18, 2010, 11:02pm UTC](https://www.ruby-forum.com/t/opening-urls/188813/7 "2010-05-18T23:02:51Z")

</div>

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](http://www.flightaware.com/live/flight/#%7Bflight%7D)”)  
browser.visible = true  
loop do  
sleep(n)  
browser.refresh  
print Time.now, “\n”  
end
