mechanize:Mechanize::Form#action
>> require 'mechanize' => true >> agent = Mechanize.new => #<Mechanize:0xb7496594 ... >> page = agent.get('http://www.google.com/') => #<Mechanize::Page {url #<URI::HTTP:0xb7489920 URL:http://www.google.co.jp/>} ... >> search_form = page.form_with(:name => "f") => #<Mechanize::Form {name "f"} ... >> search_form.action => "/search"
以下のような HTML で
<html> <head> <title>form test</title> </head> <body> <form method="get" action="cgi/foo00.cgi" name="form1"> </form> <form method="post" action="cgi/foo01.cgi" name="form2"> </form> </body> </html>
>> require 'mechanize' => true >> agent = Mechanize.new => #<Mechanize:0xb7444604 ... >> page = agent.get('http://127.0.0.1:8080/test09_form.html') => #<Mechanize::Page {url #<URI::HTTP:0xb7440d4c URL:http://127.0.0.1:8080/test09_form.html>} {meta} {title "form test"} {iframes} {frames} {links} {forms #<Mechanize::Form {name "form1"} {method "GET"} {action "cgi/foo00.cgi"} {fields} {radiobuttons} {checkboxes} {file_uploads} {buttons}> #<Mechanize::Form {name "form2"} {method "POST"} {action "cgi/foo01.cgi"} {fields} {radiobuttons} {checkboxes} {file_uploads} {buttons}>}> >> f = page.form_with(:name => "form1") => #<Mechanize::Form {name "form1"} {method "GET"} {action "cgi/foo00.cgi"} {fields} {radiobuttons} {checkboxes} {file_uploads} {buttons}> >> f.action => "cgi/foo00.cgi" >> f = page.form_with(:name => "form2") => #<Mechanize::Form {name "form2"} {method "POST"} {action "cgi/foo01.cgi"} {fields} {radiobuttons} {checkboxes} {file_uploads} {buttons}> >> f.action => "cgi/foo01.cgi"