1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "URLItem": [
12 {
13 "url": "https://download.samplelib.com/mp4/sample-5s.mp4",
14 "method": "GET",
15 "headers": {},
16 "fileName": "5s.mp4"
17 },
18 {
19 "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
20 "method": "GET",
21 "headers": {
22 "User-Agent": "Custom-Downloader/1.0"
23 }
24 },
25 {
26 "url": "https://www.reddit.com/",
27 "method": "GET",
28 "fileName": "reddit.html"
29 },
30 {
31 "url": "https://httpbin.org/bytes/2048",
32 "method": "GET"
33 },
34 {
35 "url": "https://www.youtube.com/",
36 "method": "GET"
37 },
38 {
39 "url": "https://file-examples.com/wp-content/storage/2017/02/file-sample_100kB.docx",
40 "method": "GET"
41 }
42 ],
43 "proxyConfig": {
44 "useApifyProxy": false
45 }
46};
47
48
49const run = await client.actor("dz_omar/universal-downloader").call(input);
50
51
52console.log('Results from dataset');
53console.log(`πΎ Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
54const { items } = await client.dataset(run.defaultDatasetId).listItems();
55items.forEach((item) => {
56 console.dir(item);
57});
58
59