Peter Szinek
2007-Apr-19 20:11 UTC
[Mechanize-users] Do you have any idea what could be the problem with this script?
Hello all,
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 03:34 UTC
[Mechanize-users] Do you have any idea what could be the problem with this script?
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:11 AM, Peter Szinek wrote:> 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}