Forum: Ruby mechanize - problem with downloading csv file

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E88491f72dacd0428b63df63b2b94962?d=identicon&s=25 Subhransu Behera (subhransu)
on 2009-02-24 13:47
Hi,

I am trying to download the past call details from ATnT site
in csv format.

It requires to select the bill period and click on a radio button.
Then clicking on "Submit" link downloads the call summary for
that period.

I tried to do it in mechanize in the following way, but it download
the src of the page in stead of downloading the actual CSV file.

# get the download page

page_download = agent.get "
https://www.wireless.att.com/view/billPayDownloadD...
"

# get the form for bill_period and select a bill period

bill_period_form = page_download.forms[2]
bill_period_form.field.options[2].select

# click on the csv radio button

download_format_form =  page_download.forms[3]
download_format_form.radiobuttons[1].click

# click on the submit link that downloads the csv file.

download_file = agent.click download_page.search("a")[41]
download_file.save_as("<path_to_file>.csv")

The problem I am facing in the above code is:

+ Doesn't do anything special after selecting a particular bill period
from
the select options.
+ Download the page source in stead of downloading the actual csv file.

Can you suggest something? Am I missing something here?

Thanks,
Subhransu
This topic is locked and can not be replied to.