1

I am trying to update this page by clicking a button that is outside of any forms using Ruby Mechanize. Does anyone know if this is possible? I know that I can't use the standard button submit. Below is a snippet of the html surrounding the button

<div class="details-section-contents">

  <div class="details-section-heading"></div>
  <div class="details-section-body expandable" data-load-more-section-id="reviews" data-load-more-docid="com.microsoft.office.officehub">
    <div></div>
    <button class="expand-button expand-next" style="display: block;">
        <div class="arrow-image-wrapper"></div>
        <div class="play-button"></div>
          ...
arc
  • 477
  • 2
  • 8
  • 14

1 Answers1

1

Since you haven't provided too much information about the site I just give you the general approach.

Let's say you want to click a button. This probably triggers an http request like so: http://www.somesite.com/sub?params=1234. (I am sure you can figure out the action that the button performs.)

To get he response from it you can do:

Mechanize.new.get('http://www.somesite.com/sub?params=1234').parser

NOTE: Only append the .parser method call if you want the site to be parsed as Nokogiri Node Tree.

Severin
  • 8,508
  • 14
  • 68
  • 117
  • I know I could do this, but my goal was to make a tool that works for more than one specific page on the Google Play store (a tool that can harvest app reviews given the name of the app) – arc Mar 29 '14 at 10:36
  • Also, upon closer inspection, the url doesn't change at all when the button is clicked. More items just appear on the page – arc Mar 29 '14 at 10:38
  • In that case you can't do anything with Mechanize since it is unable to interpret Javascript. – Severin Mar 29 '14 at 13:43
  • The items that get added are in the ajax response. It's all right there and Mechanize will show it to you, but you will need to figure it out. Or you can give up and use Watir. – pguardiario Mar 29 '14 at 13:46