# Use www mechanize issues

**URL:** <https://www.ruby-forum.com/t/use-www-mechanize-issues/101412>\
**Category:** Ruby\
**Created:** [August 4, 2006, 7:15pm UTC](https://www.ruby-forum.com/t/use-www-mechanize-issues/101412 "2006-08-04T19:15:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 4, 2006, 7:15pm UTC](https://www.ruby-forum.com/t/use-www-mechanize-issues/101412/1 "2006-08-04T19:15:46Z")

</div>

HI  
I am trying to download text file from [cboe.org](http://cboe.org) site. here is what i  
have done so far  
require ‘rubygems’  
require ‘mechanize’  
require ‘logger’

agent = WWW::Mechanize.new { |a| a.log = Logger.new(“mech.log”) }  
agent.user\_agent\_alias = ‘Mac Safari’  
page =  
agent.get(“[VIX - Delayed Quotes](http://www.cboe.com/delayedquote/QuoteTableDownload.aspx)”)  
search\_form = page.forms.name(“QuoteTableDownload”).first  
search\_form.fields.name(“ucQuoteTableDownloadCtl:txtTicker”).value =  
“yhoo”  
link=search\_form.fields.name(“ucQuoteTableDownloadCtl:cmdSubmit”)

# link = page.links.find {|l| l.node.text =~ /Download Text File/ }

search\_results = agent.submit(search\_form)

puts search\_results.body

My issues are

1. The cboe returns a file as my system does not have a file handler  
for it, it would have invoked a popup for me to save it. how do i  
simulate it.
2. how do i confirm if the script reached the popup stage?

Thanks

Seede

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 4, 2006, 8:06pm UTC](https://www.ruby-forum.com/t/use-www-mechanize-issues/101412/2 "2006-08-04T20:06:53Z")

</div>

Hi,

On Sat, Aug 05, 2006 at 02:15:06AM +0900, removed\_email\_address@domain.invalid wrote:

> agent.get(“[VIX - Delayed Quotes](http://www.cboe.com/delayedquote/QuoteTableDownload.aspx)”)  
> search\_form = page.forms.name(“QuoteTableDownload”).first  
> search\_form.fields.name(“ucQuoteTableDownloadCtl:txtTicker”).value =  
> “yhoo”  
> link=search\_form.fields.name(“ucQuoteTableDownloadCtl:cmdSubmit”)
> 
> # link = page.links.find {|l| l.node.text =~ /Download Text File/ }
> 
> search\_results = agent.submit(search\_form)
> 
> puts search\_results.body

It looks like the form requires you to “click” a button. Try changing

search\_results = agent.submit(search\_form)

to this:

search\_results = agent.submit(search\_form, search\_form.buttons.first)

> My issues are
> 
> 1. The cboe returns a file as my system does not have a file handler  
> for it, it would have invoked a popup for me to save it. how do i  
> simulate it.
> 2. how do i confirm if the script reached the popup stage?

Just examine the contents returned from the server to see if they are  
correct. If so, save the file, if not, fix the script. Hope this  
helps!

–Aaron
