Web Scraper Experimental Debug

No credit card required

Web Scraper Experimental Debug

Web Scraper Experimental Debug

mtrunkat/web-scraper-experimental-dbgr

No credit card required

Experimental version of Apify Web Scraper with Chrome debugger integrated

The code examples below show how to run the Actor and get its results. To run the code, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token, which you can find under Settings > Integrations in Apify Console. Learn mode

import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with API token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        {
            "url": "https://apify.com"
        }
    ],
    "pseudoUrls": [
        {
            "purl": "https://apify.com[(/[\\w-]+)?]"
        }
    ],
    "linkSelector": "a",
    "pageFunction": async function pageFunction(context) {
        // See README for context properties. If the syntax is unfamiliar see the link
        // https://javascript.info/destructuring-assignment#object-destructuring
        const { request, log, jQuery } = context;
    
        // To be able to use jQuery as $, one needs save it into a variable
        // and select the inject jQuery option. We've selected it for you.
        const $ = jQuery;
        const title = $('title').text();
    
        // This is yet another new feature of Javascript called template strings.
        // https://javascript.info/string#quotes
        log.info(`URL: ${request.url} TITLE: ${title}`);
    
        // To save data just return an object with the requested properties.
        return {
            url: request.url,
            title
        };
    },
    "proxyConfiguration": {
        "useApifyProxy": false
    },
    "initialCookies": [],
    "waitUntil": [
        "networkidle2"
    ],
    "customData": {}
};

(async () => {
    // Run the Actor and wait for it to finish
    const run = await client.actor("mtrunkat/web-scraper-experimental-dbgr").call(input);

    // Fetch and print Actor results from the run's dataset (if any)
    console.log('Results from dataset');
    const { items } = await client.dataset(run.defaultDatasetId).listItems();
    items.forEach((item) => {
        console.dir(item);
    });
})();
Developer
Maintained by Community
Actor stats
  • 62 users
  • 860 runs
  • Modified over 2 years ago

You might also like these Actors