Peter Szinek
2007-Apr-20 08:05 UTC
[Mechanize-users] Running script does not return the correct page
Hello all, I have tried to post this yesterday, but noticed I was actually not subscribed yet... Well, here we go again: If I run this script, and observe the output, the results are not there at all (try to do the same in the browser). Any suggestions? require ''rubygems'' require ''mechanize'' agent = WWW::Mechanize.new agent.user_agent_alias = ''Mac Safari'' page = agent.get("http://www.sbstransit.com.sg/iris3/bus_serviceopt.aspx") search_form = page.forms.with.name("Form1").first search_form.txtsvcno = "014" search_form.txtbusstop = ''92129'' search_results = agent.submit(search_form) open(''output.html'',''w'') {|f| f.write search_results.body} Thanks, Peter
Meng Kuan
2007-Apr-20 10:36 UTC
[Mechanize-users] Running script does not return the correct page
Hi Peter, Replace the line search_results = agent.submit(search_form) with this search_results = search_form.submit(search_form.buttons.first) cheers, mengkuan On 20 Apr 2007, at 4:05 PM, Peter Szinek wrote:> Hello all, > > I have tried to post this yesterday, but noticed I was actually not > subscribed yet... Well, here we go again: > > If I run this script, and observe the output, the results are not > there > at all (try to do the same in the browser). Any suggestions? > > require ''rubygems'' > require ''mechanize'' > > agent = WWW::Mechanize.new > agent.user_agent_alias = ''Mac Safari'' > page > agent.get("http://www.sbstransit.com.sg/iris3/bus_serviceopt.aspx") > search_form = page.forms.with.name("Form1").first > search_form.txtsvcno = "014" > search_form.txtbusstop = ''92129'' > search_results = agent.submit(search_form) > open(''output.html'',''w'') {|f| f.write search_results.body} > > Thanks, > Peter > _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mechanize-users
Peter Szinek
2007-Apr-20 14:27 UTC
[Mechanize-users] Running script does not return the correct page
Meng Kuan wrote:> Hi Peter, > > Replace the line > > search_results = agent.submit(search_form) > > with this > > search_results = search_form.submit(search_form.buttons.first)Thanks, that did the trick! Cheers, Peter