Im working on submitting the search form for yellowpages.com, but when I do pretty print page I notice in the name field it is blank. How would I tell mechanize to locate that form if the name field is blank?
require 'mechanize'
agent = Mechanize.new
page = agent.get('http://www.yellowpages.com')
pp page
Output:
#<Mechanize::Form
{name nil}
{method "GET"}
{action "/search"}
{fields
[text:0x3fd6990db510 type: text name: search_terms value: ]
[text:0x3fd6990db36c type: text name: geo_location_terms value: Dallas, TX]
[hidden:0x3fd6990db13c type: hidden name: tracks value: true]}
{radiobuttons}
{checkboxes}
{file_uploads}
{buttons [button:0x3fd6990df87c type: submit name: value: Search]}>}>
The form has an action
attribute; specify that information:
page.form_with(:action => '/search') do |form|
...
end