Crawler Puppeteer avatar

Crawler Puppeteer

Try for free

No credit card required

Go to Store
Crawler Puppeteer

Crawler Puppeteer

jancurn/crawler-puppeteer
Try for free

No credit card required

Copy of https://github.com/apifytech/actor-crawler-puppeteer

You can access the Crawler Puppeteer programmatically from your own JavaScript applications by using the Apify API. You can also choose the language preference from below. To use the Apify API, you’ll need an Apify account and your API token, found in Integrations settings in Apify Console.

1import { ApifyClient } from 'apify-client';
2
3// Initialize the ApifyClient with your Apify API token
4// Replace the '<YOUR_API_TOKEN>' with your token
5const client = new ApifyClient({
6    token: '<YOUR_API_TOKEN>',
7});
8
9// Prepare Actor input
10const input = {
11    "startUrls": [
12        {
13            "url": "http://example.com"
14        },
15        {
16            "url": "http://iana.org"
17        }
18    ],
19    "pseudoUrls": [
20        {
21            "purl": "https://www.iana.org/[((?!\\.pdf$).)*]"
22        }
23    ],
24    "linkSelector": "a",
25    "pageFunction": async ({ request, page, keyValueStore, log }) => {
26        const title = await page.title();
27        log.info(`Title of page with url ${request.url} is: ${title}`);
28        await keyValueStore.setValue(Math.random().toString(36), { title });
29        return { title }
30    },
31    "proxyConfiguration": {
32        "useApifyProxy": false
33    }
34};
35
36// Run the Actor and wait for it to finish
37const run = await client.actor("jancurn/crawler-puppeteer").call(input);
38
39// Fetch and print Actor results from the run's dataset (if any)
40console.log('Results from dataset');
41console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
42const { items } = await client.dataset(run.defaultDatasetId).listItems();
43items.forEach((item) => {
44    console.dir(item);
45});
46
47// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

Crawler Puppeteer API in JavaScript

The Apify API client for JavaScript is the official library that allows you to use Crawler Puppeteer API in JavaScript or TypeScript, providing convenience functions and automatic retries on errors.

Install the apify-client

npm install apify-client

Other API clients include:

Developer
Maintained by Community

Actor Metrics

  • 1 monthly user

  • 2 stars

  • 50% runs succeeded

  • Created in Jan 2019

  • Modified 6 years ago

Categories