html - Submitting a form via an <a> element with Ruby Mechanize -


i've got set of pages i'm trying scrape mechanize in ruby. on of pages, redirect page wants me fill out select-list form , submit it. problem button submits form, <a> element. looks this:

<a class="css_class" href="#" onclick="runsomescript; return false;">   <span>     enter   </span> </a> 

the magic seems happening runsomescript script; thing seems bypass redirect page , take me page data i'm trying scrape. unfortunately, can't seem figure out how submit form mechanize. tried using mechanize#click method on <a> element passing in <a>'s href attribute it, hasn't seemed work either. how automate click on link (i.e., submission of form) and/or run runsomescript script in order submit form on redirect page?

i think can directly find form , submit mechanize i.e

# if condition checks if form exists id add fields , submit     if page.search("#ctl00_contentplaceholder1_ctrlresults_gvresults_ctl01_lbnext").count > 0               form = page.forms.first               form.add_field! "__eventtarget", "ctl00$contentplaceholder1$ctrlresults$gvresults$ctl01$lbnext"               form.add_field! "__eventargument", ""               page = form.submit 

in case can find form using id or use

form = page.forms.first   # whatever want form ,  page = form.submit 

Comments