I would like to load more data onto the page I'm visiting by clicking the 'Show More' button, which is at the bottom of the page.
Mechanize is showing me this button as a link (see below).
From the research I've done, I should be able to click this button with the code listed below. However, when I view the list of divs that I'm hoping will be longer, I see the count is the same as before, which to me means something isn't working as expected.
On another thread, I saw that buttons can sometimes be 'disguised' as part of forms. I looked at the page and it has three forms. However I do not believe any of these forms are associated with this button because the button does not have any fields associated with it.
When I do invoke the click method below, it does look like the click was successful (I can see some sort of reload in terminal) but .children.count does not change.
#assume I already did mechanize.get(url) and I'm on the site.
#I also did a mechanize.page.links.find to get the show more button
mechanize = Mechanize.new
showMore = #<Mechanize::Page::Link "Show More" "#">
pageWithMore = mechanize.click(showMore)
# check children of div to see if count is longer
mechanize.page.css('div.results-container').children.count
# repeatedly returns 51 after 'click' invoke
I expect the .children.count to be closer to 100 after invoking the click method and then ~150 after invoking a second time.
Aucun commentaire:
Enregistrer un commentaire