How to use waitForSelector in Puppeteer to get all <p> tags on a page?

10 Replies, 1917 Views

Hey everyone,

So I’ve been messing around with Puppeteer and trying to figure out how to use waitforselector puppeteer get all p tags on a page. I know it’s probably basic for some of you, but I’m kinda stuck lol.

Here’s what I’m trying to do: I want to wait for all the `<p>` tags to load on a page and then grab them. I’ve tried using `page.waitForSelector('p')`, but it only waits for the first `<p>` tag, not all of them.

Is there a way to make sure *all* the `<p>` tags are loaded before I use something like `page.$$('p')` to get them? Or am I overcomplicating this?

Any help would be awesome, thanks in advance!

(Also, sorry if this has been asked before, I tried searching but couldn’t find exactly what I needed.)

Messages In This Thread
How to use waitForSelector in Puppeteer to get all <p> tags on a page? - by - 30-08-2024, 05:36 PM



Users browsing this thread: 1 Guest(s)