HI
I am trying to download text file from 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("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
Hi,
HI
I am trying to download text file from 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("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
···
On Sat, Aug 05, 2006 at 02:15:06AM +0900, junkone@rogers.com wrote: