Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i make customCrawl click on specific elements? #384

Open
michaelpapesch opened this issue Feb 21, 2022 · 1 comment
Open

How can i make customCrawl click on specific elements? #384

michaelpapesch opened this issue Feb 21, 2022 · 1 comment

Comments

@michaelpapesch
Copy link

I want to make my customcrawl click on elements.
They dont have a href, but a js onclick event.

Is this possible, and how and where in the code can this be done?

My code is:

const HCCrawler = require('headless-chrome-crawler');

(async () => {
    const crawler = await HCCrawler.launch({
        headless: true,
        args: [
            '--ignore-certificate-errors',
            '--no-sandbox',
            '--disable-setuid-sandbox',
            '--disable-accelerated-2d-canvas',
            '--disable-gpu'
        ],
        maxDepth: 8,
        waitUntil: "networkidle0",
        customCrawl: async (page, crawl) => {

            await page.setViewport({
                width: 1200,
                height: 800
            });

            const result = await crawl();
            return result;
        },
        onSuccess: result => {
        },
        onError: error => {
            console.log(error);
        },
    });
    await crawler.queue(url);
    await crawler.onIdle();
    await crawler.close().then(() => connection.end());
})();
@michaelpapesch michaelpapesch changed the title How can i make customcrawler click on specific elements? How can i make customCrawl click on specific elements? Feb 21, 2022
@iamprageeth
Copy link

I think you can do this in evaluatePage function using jquery

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants