Reputation: 65
I'm trying to make a web-scraper in Node JS and I've hit a roadblock. I need to click on a button BUT, if I'm not mistaken, Node doesn't actually render the web-page like a browser would so I can't use a selector or X-Path.
How then, could I click a specific button with the value "yes" if I can't use the selector or X-path? There's no id unique to only the yes button.
I'm asking this because I want to parse a specific web-page but I get redirected to a page that asks me to press two buttons. Pressing 'Yes' will bring me to the page I want. Pressing 'No' will obviously stop me from going forward.
Is there any way to do what I want within the confines on Node without having to resort to something like JSDOM?
Here's part of the HTML i'm working with:
<div class="buttons">
<button class="c-btn c-btn-primary" type="submit" name="bigbutton" value="no">no thank you</button>
<button class="c-btn c-btn-primary" type="submit" name="bigbutton" value="yes">continue</button>
</div>
I tried using something like this:
document.getElementByID("selector").click()
but was returned with 'ReferenceError: document is not defined'.
Upvotes: 1
Views: 6787