Wait For Selector

waitForSelector: string | null;

What's This?

The waitForSelector option tells the scraper to wait for a specific part of the website to appear before it finishes its job. It's like telling the scraper, "Don't finish until you see this specific thing on the page."

How Does it Work?

  • Default (waitForSelector: null) The scraper just fetches the website content based on its usual rules or the mode you've set.

  • With (waitForSelector=‘.example-class’): The scraper patiently waits until it sees a specific part of the website (like a button or an image) that matches the description you provided (in this case, something with the class ‘.example-class’).

When Should I Use This?

If there's a crucial part of the website that takes a bit longer to appear (maybe it's loaded separately or appears after a delay), use waitForSelector. It ensures the scraper doesn't finish its job until that part is ready and captured.

Methods

waitForSelector(boolean) 

###Configuration Name: waitForSelector

Initializing Scraper

const GeonodeScraperApi = require('geonode-scraper-api');
const scraper = new GeonodeScraperApi('<Your_username>', '<Your_password>');

Using Method

scraper.waitForSelector(‘.example-class’);
scraper.scrape('https://example.com/')

Using Configuration Object

const config = { waitForSelector: '.example-class' };
scraper.scrape('https://example.com/', config);