1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "sparql": `SELECT ?person ?personLabel ?birthDate ?birthPlaceLabel ?deathDate ?countryLabel WHERE {
12 ?person wdt:P166 wd:Q38104 .
13 ?person wdt:P31 wd:Q5 .
14 OPTIONAL { ?person wdt:P569 ?birthDate . }
15 OPTIONAL { ?person wdt:P19 ?birthPlace . }
16 OPTIONAL { ?person wdt:P570 ?deathDate . }
17 OPTIONAL { ?person wdt:P27 ?country . }
18 SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
19}
20LIMIT 300`,
21 "maxResults": 300,
22 "proxyConfiguration": {
23 "useApifyProxy": true
24 }
25};
26
27
28const run = await client.actor("logiover/wikidata-scraper").call(input);
29
30
31console.log('Results from dataset');
32console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
33const { items } = await client.dataset(run.defaultDatasetId).listItems();
34items.forEach((item) => {
35 console.dir(item);
36});
37
38