Google Maps Scraper: extendOutputFunction failing to skip existing placeIds
Hello everyone, I'm using the Google Maps Scraper Actor in a workflow and attempting to implement logic to skip places that I have already collected in previous runs, based on their unique placeId. My setup involves querying a database for all previously collected placeIds and passing that list to the Actor's input as an array called customData.ignoreIds.
The Problem: The filtering logic is correctly defined in the Actor's input, but the Actor is still collecting and outputting places whose placeId is present in the ignoreIds list. I have verified the workflow is sequential (Database $\rightarrow$ JS $\rightarrow$ Actor).I have verified the ignoreIds array correctly contains the duplicate IDs in the Actor's input.The Actor log shows no errors related to the custom function.This suggests the extendOutputFunction is either not being executed or is failing silently within the Actor's environment.
My Implementation
"async ({ item, data, customData }) => {" +
" const pid = item.placeId item.googleId item.place_id (data && (data.placeId data.place_id));" +
" // Convert to a Set for faster lookup" +
" const ignore = Array.isArray(customData?.ignoreIds) ? new Set(customData.ignoreIds.map(String)) : new Set();" +
" " +
" // CRITICAL STEP: Skip item if its ID is in the ignore set" +
" if (pid && ignore.has(String(pid))) return null;" +
" " +
" return item;" +
"}"
My Questions are:
1- Is there a known restriction or limitation in the Google Maps Scraper Actor (or its underlying environment) that prevents the execution of the extendOutputFunction when passed as a string parameter, especially when using modern JS features like Set?
2- Has anyone successfully implemented this type of placeId skipping filter inside this Actor? If so, could you share a confirmed working function structure?
1 Reply
Hey @wael kodmani, thank you for your questions. First of all, could you please try to format your implementation a little better? I'm having trouble understanding what's going on from what you have sent.
My general idea of what you want to do is to provide a custom filtering function for Google Maps Scraper results, which would have a set of IDs to skip.
As I mentioned, I don't quite understand from your example, but we should identify a few key points:
1. is the function really called for each result?
2. Is the function getting the correct data with the blacklisted IDs?
I don't think set should be a problem, but you can easily test the same functionality using object { [key: string]: boolean } or something.
Another tip - there is an issues section for each Actor on Apify Console so that you can ask your questions directly to the Actor devs.
Good luck