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 "proxyConfiguration": {
23 "useApifyProxy": false
24 },
25 "customData": {},
26 "pageFunction": async function pageFunction(context) {
27 const { page, request, log } = context;
28 const title = await page.title();
29 log.info(`URL: ${request.url} TITLE: ${title}`);
30 return {
31 url: request.url,
32 title
33 };
34 },
35 "preGotoFunction": async function preGotoFunction({ request, page, Apify }) {
36
37 },
38 "initialCookies": [],
39 "waitUntil": [
40 "networkidle2"
41 ]
42};
43
44
45const run = await client.actor("barry8schneider/puppeteer20191228").call(input);
46
47
48console.log('Results from dataset');
49console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
50const { items } = await client.dataset(run.defaultDatasetId).listItems();
51items.forEach((item) => {
52 console.dir(item);
53});
54
55