Figranium Templates
arrow_back
Icon

Preset / Lead Gen

Google Maps Lead Scraper

F
figranium
AGENTLead Gen

account_treeAutomation Steps

1

wait

Value: 2

2

javascript

Value: var feed = document.querySelector('div[role="feed"]'); if (feed) { feed.scrollTop = feed.scrollHeight; } return { scrolled: true };

3

wait

Value: 3

4

javascript

Value: var feed = document.querySelector('div[role="feed"]'); if (feed) { feed.scrollTop = feed.scrollHeight; } return { scrolled: true };

5

wait

Value: 3

6

javascript

Value: return (function() { const feed = document.querySelector('[role="feed"]'); if (!feed) return []; const entries = feed.querySelectorAll(':scope > div, :scope > a'); return Array.from(entries).map(card => { const nameEl = card.querySelector('h1, h2, h3, [class*="fontHeadlineSmall"], [class*="qBF1Pd"]'); if (!nameEl) return null; const name = nameEl.innerText.trim(); if (!name || name === 'النتائج') return null; const cardText = card.innerText || ''; const ratingMatch = cardText.match(/\b(\d\.\d)\b/); const rating = ratingMatch ? ratingMatch[1] : ''; const phoneMatch = cardText.match(/\+1\s*\d{3}-\d{3}-\d{4}/); const phone = phoneMatch ? phoneMatch[0] : ''; let address = ''; const addrParts = cardText.split('\n'); if (addrParts.length > 2) { const line = addrParts.find(p => p.includes('·') || p.includes('•')); if (line) { const parts = line.split(/[·•]/); address = parts[parts.length - 1].trim(); } } if (!address) { address = cardText.replace(name, '').replace(rating, '').replace(phone, '').trim().split('\n')[0]; } let website = ''; const links = card.querySelectorAll('a[href]'); for (let i = 0; i < links.length; i++) { const href = links[i].getAttribute('href') || ''; if (href.startsWith('http') && !href.includes('google.com')) { website = href; break; } } return { name, rating, address, phone, website }; }).filter(r => r && r.name); })()

7

set

Value: {$block.output}

codeExtraction Script

var parsed = {$extractedResults};

return parsed
  .map(function (item) {
    var name = (item.name || "").trim();
    var rating = (item.rating || "").trim();
    var address = (item.address || "").trim();
    var phone = (item.phone || "").trim();
    var website = (item.website || "").trim();

    // If the extracted "address" is actually a phone number, move it.
    var phonePattern = /^\+?[\d\s().-]{7,}$/;

    if (!phone && phonePattern.test(address)) {
      phone = address;
      address = "";
    }

    return {
      Name: name,
      Rating: rating,
      Address: address,
      Phone: phone,
      Website: website
    };
  })
  .filter(function (item) {
    // Remove Google Maps UI / non-business results.
    if (!item.Name) return false;

    var junkNames = [
      "Results",
      "Get the most out of Google Maps",
      "Get the most out of Google Maps\nSign in"
    ];

    if (junkNames.indexOf(item.Name) !== -1) return false;

    // Remove rows that contain essentially no useful business data.
    if (
      !item.Rating &&
      !item.Address &&
      !item.Phone &&
      !item.Website
    ) {
      return false;
    }

    return true;
  });

Configuration