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://crawlee.dev"
14 }
15 ],
16 "maxCrawlingDepth": 1,
17 "maxRequestsPerCrawl": 1,
18 "requestTimeout": 30,
19 "linkSelector": "a[href]",
20 "linkPatterns": [
21 ".*crawlee\\.dev.*"
22 ],
23 "pageFunction": `from typing import Any
24 from crawlee.crawlers import PlaywrightCrawlingContext
25
26 async def page_function(context: PlaywrightCrawlingContext) -> Any:
27 url = context.request.url
28 title = await context.page.locator("title").first.inner_text()
29 return {'url': url, 'title': title}`,
30 "proxyConfiguration": {
31 "useApifyProxy": true
32 }
33};
34
35
36const run = await client.actor("josef.prochazka/camoufox-scraper").call(input);
37
38
39console.log('Results from dataset');
40console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
41const { items } = await client.dataset(run.defaultDatasetId).listItems();
42items.forEach((item) => {
43 console.dir(item);
44});
45
46