Finding CID and LRD of a business page on Google

1k views Asked by At

I want to know how to find the LRD and CID for an specific business page on Google.

The sample URL I'm trying to construct as follows

https://www.google.com/#q=takeout+banani&lucid="CID"&lrd=0x3755c7120ec9e20f:0x8889d4d79e711995,3

What I've found out so far is there isn't any direct way to find both CID and LRD.

I have to make two API calls to get CID which looks like as follows,

"url": "https://maps.google.com/?cid=4839020573042712727",

but is there any other way to or direct FIELD in api like the place_id below?

"place_id": "ChIJrQFQG6PHVTcRl6AErZKnJ0M"

Now comes to the LRD part, HOW CAN I FIND IT? In this details API

https://maps.googleapis.com/maps/api/place/details/json?reference="Referense key from place request api"&sensor=true&key="Your API Key"

There is no direct field also for LRD.

So how can i get or find LRD 0x[HEX_CODE1]:0x[HEX_CODE2] in these formate.

I'm linking the stackoverflow questions below as reference.

How to get the cid in the Google Place URL?

Google Places API - Find a company's CID and LRD

2

There are 2 answers

0
José Manuel Blasco On

Read this answer to obtain the CID: How to get the cid in the Google Place URL?

Two API requests and you'll have the CID of a business programmatically.

EDIT ----------

The LRD is CID in hexadecimal. You can use this function to:

function dec2hex($number)
{
    $hexvalues = array('0','1','2','3','4','5','6','7',
               '8','9','A','B','C','D','E','F');
    $hexval = '';
     while($number != '0')
     {
        $hexval = $hexvalues[bcmod($number,'16')].$hexval;
        $number = bcdiv($number,'16',0);
    }
    return $hexval;
}

So you can build the Google Review Url like this:

$business_url = "https://www.google.com/search?q=NAMEOFBUSINESS&ludocid=YOURCID#lrd=0x0:0xYOURHEXCID,1";
0
sharmanhall On

Use my Tampermonkey / GreaseMonkey script! It prints the CID and PID to console for you when you search the google profile. I made this work for Google Search results, not yet for Google Maps.

It prints the result to your browser's console in big bold green text so it's easy to spot!


    // ==UserScript==
    // @name Extract Google Business PlaceID and CID
    // @namespace https://example.com/
    // @version 0.1
    // @description Extracts the data-pid value from a Google Business profile page
    // @author sharmanhall
    // @match https://www.google.com/*
    // @grant none
    // ==/UserScript==
    
    // https://www.google.com/maps?cid=[CID]
    // https://www.google.com/maps/place/?q=place_id:[PID]
    
    (function() {
        'use strict';
    
        // Wait for the page to fully load
        window.addEventListener("load", function() {
            // BUSINESS NAME: Find the business name element on the page
            let businessNameElement = document.querySelector('h2[data-attrid="title"]');
            if (businessNameElement) {
                // Extract the business name from the element
                let businessName = businessNameElement.textContent.trim();
                console.log('%cBusiness name:','font-size: 16px; font-weight: bold; color:green', businessName);
            } else {
                console.error("Could not find the business name element on the page");
            }
            // DATA-PID: Find the "Write a Review" button on the page
            let reviewButton = document.querySelector("#wrkpb");
            if (reviewButton) {
                // Extract the data-pid value from the button
                let dataPid = reviewButton.getAttribute("data-pid");
                console.log('%cdata-pid:','font-size: 16px; font-weight: bold; color:green', dataPid);
            } else {
                console.error("Could not find the 'Write a Review' button on the page");
            }
    
            // DATA-CID: Find the first search result link on the page
            let searchResultLink = document.querySelector('a[jscontroller="wuU7pb"]');
            if (searchResultLink) {
                // Extract the data-rc_ludocids value from the link
                let dataCid = searchResultLink.getAttribute("data-rc_ludocids");
                console.log('%cdata-cid:','font-size: 16px; font-weight: bold; color:green',dataCid);
            } else {
                console.error("Could not find the data-cid search result link on the page");
            }
        });
    })();

Console of the tampermonkey script exporting CID PID and Business name