I'm using Mechanize to scrape Google Wallet for Order data. I am capturing all the data from the first page, however, I need to automatically link to subsequent pages to get more info.
The #purchaseOrderPager-pagerNextButton will move to the next page so I can pick up more records to capture. The element looks like this. I need to click on it to keep going.
<a id="purchaseOrderPager-pagerNextButton" class="kd-button small right"
href="purchaseorderlist?startTime=0&...
;currentPageStart=1&currentPageEnd=25&inputFullText=">
<img src="https://www.gstatic.com/mc3/purchaseorder/page-right.png"></a>
However, when I try the following I get an error:
next_page = @orders_page.search("#purchaseOrderPager-pagerNextButton")
next_page.click
The error:
undefined method `click' for #<Nokogiri::XML::NodeSet:0x007f9019095550> (NoMethodError)
click
is a method of Mechanize
class.
Try following form.
next_page = @orders_page.at("#purchaseOrderPager-pagerNextButton")
mechanize_instance.click(next_page)
NOTE Replace mechanize_instance
with actual variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With