Tripadvisor Scraper
Pay $3.00 for 1,000 results
Tripadvisor Scraper
Pay $3.00 for 1,000 results
This unofficial Tripadvisor API is a data extraction tool able to get data on hotels, restaurants, things to do, vacation rentals, attractions, tours, and public trips. Get pricing, contact details, amenities, awards, ratings, and more. Download your data in Excel, JSON, CSV, and other formats.
Do you want to learn more about this Actor?
Get a demoI get error executing this actor via api: ApifyApiError: Insufficient permissions for the Actor. Make sure you're passing a correct API token and that it has the required permissions. clientMethod: ActorClient.start statusCode: 403 type: insufficient-permissions attempt: 1 httpMethod: post path: /v2/acts/maxcopell~tripadvisor/runs
Hi, thanks for opening this issue!
Can you share the code for your integration? This looks like an issue with the token... Are you using the correct Personal API token from the https://console.apify.com/settings/integrations tab? The 403
error is often thrown if you've just forgot to include the token.
Thanks!
import { ApifyClient } from 'apify-client'; import fs from 'fs'; import path from 'path'; import XLSX from 'xlsx';
// Initialize the ApifyClient with your Apify API token const client = new ApifyClient({ token: process.env.APIFY_API_TOKEN, });
// Prepare Actor input const input = { "locationFullName": "São Paulo", "maxItemsPerQuery": 15, "includeTags": true, "includeNearbyResults": false, "includeAttractions": true, "includeRestaurants": true, "includeHotels": true, "includeVacationRentals": false, "checkInDate": "", "checkOutDate": "", "includePriceOffers": false, "includeAiReviewsSummary": false, "language": "pt", "currency": "BRL" };
// Run the Actor and wait for it to finish try { const run = await client.actor("maxcopell/tripadvisor").call(input);
1// Fetch Actor results from the run's dataset (if any) 2console.log('Results from dataset'); 3console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`); 4const { items } = await client.dataset(run.defaultDatasetId).listItems(); 5items.forEach((item) => { 6 const timestamp = new Date().toISOString().replace(/[-:]/g, '').replace('T', '_').split('.')[0]; 7 const jsonFileName = `export/json/${item.id}_${timestamp}.json`; 8 const excelFileName = `export/excel/${item.id}_${timestamp}.xlsx`; 9 10 // Create directories if they do not exist 11 if (!fs.existsSync('export/json')) { 12 fs.mkdirSync('export/json', { recursive: true }); 13 } 14 if (!fs.existsSync('export/excel')) { 15 fs.mkdirSync('export/excel', { recursive: true }); 16 } 17 18 // Save JSON file 19 fs.writeFileSync(jsonFileName, JSON.stringify(item, null, 2)); 20 21 // Convert JSON to Excel and save it 22 const workbook = XLSX.utils.book_new(); 23 const worksheet = XLSX.utils.json_to_sheet([item]); 24 XLSX.utils.book_append_sheet(workbook, worksheet, 'Data'); 25 XLSX.writeFile(workbook, excelFileName); 26 27 console.log(`Saved data for ${item.name} to JSON and Excel files.`); 28});
} catch (error) { console.error('Erro ao executar o ator:', error); }
Thanks for providing the code! It looks good, but the process.env.APIFY_API_TOKEN
value could still be undefined
, which would cause the 403 error.
Could you try attaching this at the start of the file?
1if (!process.env.APIFY_API_TOKEN) { 2 throw new Error('process.env.APIFY_API_TOKEN is not defined'); 3}
This will fail the code if the, if the variable is undefined. Let me know the outcome :)
You nailed it.
I haven't initialized the .env
Thanks!!
- 617 monthly users
- 74 stars
- 97.7% runs succeeded
- 3.5 days response time
- Created in Nov 2019
- Modified 3 days ago