A B
A B

Reputation: 65

Node JS Click Button on Page

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

Answers (1)

jupi
jupi

Reputation: 521

Have you tried to use Zombie? I've used and worked well! This link is very helpful, since clarify quickly how to perform actions.

Upvotes: 1

Related Questions