1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "startUrls": [
12 {
13 "url": "https://apify.com"
14 }
15 ],
16 "pseudoUrls": [
17 {
18 "purl": "https://apify.com[(/[\\w-]+)?]"
19 }
20 ],
21 "linkSelector": "a",
22 "pageFunction": async function pageFunction(context) {
23 const { page, request, log } = context;
24 const title = await page.title();
25 log.info(`URL: ${request.url} TITLE: ${title}`);
26 return {
27 url: request.url,
28 title
29 };
30 },
31 "proxyConfiguration": {
32 "useApifyProxy": false
33 },
34 "customData": {},
35 "initialCookies": [],
36 "preGotoFunction": async function preGotoFunction({ request, page, Apify }) {
37
38 }
39};
40
41
42const run = await client.actor("apify/puppeteer-scraper").call(input);
43
44
45console.log('Results from dataset');
46console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
47const { items } = await client.dataset(run.defaultDatasetId).listItems();
48items.forEach((item) => {
49 console.dir(item);
50});
51
52