Apify Discord Mirror

Updated 3 weeks ago

Loadtime

Hello,

Is there a way to get the load time of a site from crawlee in headless mode? I'm using PlaywrightCrawler.

Thanks!
P
B
2 comments
Hi @BOBPG :

Do you have something like this in your mind?
Plain Text
const crawler = new PlaywrightCrawler({
    // ...
    preNavigationHooks: [async ({ request }, gotoOptions) => {
        requestStartTimes.set(request.id!, Date.now());
        gotoOptions!.waitUntil = 'load';
    }],
    requestHandler: async ({ request, log }) => {
        const loadingTime = Date.now() - requestStartTimes.get(request.id!)!;
        log.info(`Loading ${request.url} took ${loadingTime / 1000}s`);
    },
});
Someting like this looks great, i'm going to try this, thanks!
Add a reply
Sign up and join the conversation on Discord