Method: Mechanize#submit
- Defined in:
- lib/mechanize.rb
#submit(form, button = nil, headers = {}) ⇒ Object
Submits form
with an optional button
.
Without a button:
page = agent.get('http://example.com')
agent.submit(page.forms.first)
With a button:
agent.submit(page.forms.first, page.forms.first..first)
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 |
# File 'lib/mechanize.rb', line 598 def submit(form, = nil, headers = {}) form.() if case form.method.upcase when 'POST' post_form(form.action, form, headers) when 'GET' get(form.action.gsub(/\?[^\?]*$/, ''), form.build_query, form.page, headers) else raise ArgumentError, "unsupported method: #{form.method.upcase}" end end |