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