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/billPayDownloadDetail.doview?execdownloadPage=true " # 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, Shubh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/mechanize-users/attachments/20090224/9b5c3ce8/attachment-0001.html>
One thing to be aware of is that Mechanize doesn''t interpret Javascript. If the page changes dynamically as you select things on the page, Mechanize will not recognize these changes. If this is the problem you are having, you will have to have the script do whatever the Javascript is doing to get everything right. Matt White ________________________________ From: subhransu behera <arya.subhransu at gmail.com> To: mechanize-users at rubyforge.org Sent: Tuesday, February 24, 2009 1:32:08 AM Subject: [Mechanize-users] problem scrapping ATnT site 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/billPayDownloadDetail.doview?execdownloadPage=true" # 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, Shubh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/mechanize-users/attachments/20090224/6e39be00/attachment.html>
Hi Matt, I did exactly what you suggested. And now it works as expected. Thanks a ton buddy! Regards, Shubh On Tue, Feb 24, 2009 at 8:48 PM, Matt White <whitethunder922 at yahoo.com>wrote:> One thing to be aware of is that Mechanize doesn''t interpret Javascript. If > the page changes dynamically as you select things on the page, Mechanize > will not recognize these changes. If this is the problem you are having, you > will have to have the script do whatever the Javascript is doing to get > everything right. > > Matt White > > ------------------------------ > *From:* subhransu behera <arya.subhransu at gmail.com> > *To:* mechanize-users at rubyforge.org > *Sent:* Tuesday, February 24, 2009 1:32:08 AM > *Subject:* [Mechanize-users] problem scrapping ATnT site > > 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/billPayDownloadDetail.doview?execdownloadPage=true > " > > # 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, > Shubh > > > _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mechanize-users >-- Innovator, Pune - India Phone : (+91)-98605-59976 Blog : http://sbehera.livejournal.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/mechanize-users/attachments/20090225/fdbd4090/attachment.html>