1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "queries": [
12 "hotels in New York",
13 "best restaurants in Paris"
14 ],
15 "searchUrls": [
16 {
17 "url": "https://www.google.com/search?q=web+scraping"
18 }
19 ],
20 "maxPagesPerQuery": 1,
21 "resultsPerPage": 10,
22 "countryCode": "us",
23 "languageCode": "en",
24 "includeAds": true,
25 "includePeopleAlsoAsk": true,
26 "includeRelatedSearches": true,
27 "proxyConfiguration": {
28 "useApifyProxy": true,
29 "apifyProxyGroups": [
30 "RESIDENTIAL"
31 ]
32 },
33 "maxConcurrency": 3
34};
35
36
37const run = await client.actor("happitap/google-search-scraper").call(input);
38
39
40console.log('Results from dataset');
41console.log(`πΎ Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
42const { items } = await client.dataset(run.defaultDatasetId).listItems();
43items.forEach((item) => {
44 console.dir(item);
45});
46
47