algorithm - 逆向工程 Google "Write a Review"链接 URL

标签 algorithm google-maps hex

在 Google 本地列表中,有一个 URL 可以将用户直接带到显示商家评论的弹出窗口。这是一个例子:

https://www.google.com/search?q=Massage+Envy+-+Arrowhead&ludocid=12682026813239828050#lrd=0x872b682580f9e59b:0xafff9c31c3239e52,1

每个营业地点在 URL 中都有一个数字 ID(在示例中为 12682026813239828050),并在 #lrd 参数中以十六进制表示该数字。

我有所有的数字 ID,需要通过确定十六进制段的形成方式来生成这些 URL。对于 ID 可以用 16 个十六进制字符表示的位置,这很容易。 URL 段只是 0x0:0x[hexstring] 例如:

4134566830992571874 => 0x0:0x3960eea07d6cbe00

但是当数字太长时,它被分成两个十六进制字符串,我无法确定第一个的来源。我举了两个例子:

14384749138104818286 => 0x872b0445e4ee5e9b:0xc7a0e5209fd81a6e
15716027411522919173 => 0x872b00074aa36265:0xda1a8ba9e8201b05

SECOND 十六进制字符串转换为 CLOSE 数字。在示例中:

c7a0e5209fd81a6e => 14384749138104818 (missing the last 3 digits)
da1a8ba9e8201b05 => 15716027411522918 (missing the last 3 digits and off by 1000)

这是一个成功转换它们的网站:https://pleper.com/index.php?do=tools&sdo=google_review_link&url=4134566830992571874

谁能帮我确定生成这些的方法?如果有另一个堆栈站点对此更好,请也将我引导到那里。谢谢!

最佳答案

回答问题。以下是留下 5 星评论的 google lrd 的当前分割:

#lrd=0x6b12ae37b47f5b37:0x8eaddfcd1b32ca52,3,5

据我所知,这是分割:

lrd = 
[ 0x6b12ae37b47f5b37 ] = Unknown. What does this number represent? 
: 
[ 0x8eaddfcd1b32ca52 ] = google cid converted to hex 
[ ,3 ] = The review type. 1 for reviews, 2 for write review, 3 also write     review
[ ,5 ] = The review rating to pre-fill on the modal

如果您正在寻找创建评论链接的解决方案,这可能会有所帮助。解决该问题的方法是使用 google places api。这将允许您从 api 查询业务 place_id 并将其与评论链接一起使用谷歌允许您用作公共(public)评论链接,如下例所示:

https://search.google.com/local/writereview?placeid= [place_id]

有关此链接的更多信息:Google review help

这仍然不允许您获得 google 在 google 搜索上创建的实际链接,或将评论评级附加到评论模式的预填充中,如下例所示:

https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=google+syndey&*&lrd=0x6b12ae37b47f5b37:0x8eaddfcd1b32ca52,3,5

这个问题的解决方案可以通过使用我们使用 place_id 创建的第一个链接并从响应 header 获取返回位置的 curl 请求来解决。

/* this is a php example curl */ 

$id = "ChIJN1t_tDeuEmsRUsoyG83frY4";

/* this will return the review url for a 
google place account. 
@param (string) $id = the google place_id 
@return (string|false) the google review url 
or false on error */ 
function getReviewUrl($id)
{ 
    $url = "https://search.google.com/local/writereview?placeid=" . $id; 

    /* we need to setup headers to show a user agent 
    to stop google from redirecting to a 404 because 
    the request is coming from a curl */ 
    $header = array(
        'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36'
    );

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_URL, $url);
    $out = curl_exec($ch);

    $location = false; 
    preg_match('/^(?:Location:(.*))$/mi', $out, $matches);
    if(isset($matches[1]))
    { 
        $location = $matches[1]; // this is the full review url
    }
    curl_close($ch);
    return $location; 
}

echo getReviewUrl($id);

这将返回完整的谷歌评论 url,您可以轻松地在其结尾添加“,5”以将评级预填充为 5 星。

关于algorithm - 逆向工程 Google "Write a Review"链接 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39536137/

相关文章:

arrays - 在二维数组中搜索相邻的相同对象

java - 如何自动从类数组转换为数组类

java - 如何在谷歌地图中绘制gpx文件

google-maps - 使用 VueJs 选择位置后重置谷歌自动完成输入值

python - 将十进制转换为十六进制python

ios - 从文件 IOS 中读取整数

c++ - 位操作 : Harder Flipping Coins

java - 交织字符串的动态规划问题解决方案

android google maps Polygon 添加圆孔

与所有其他来源不同的十六进制除法的 C 输出