调用 API 获取 Chrome 网上应用店中的用户数量?

发布于 2024-11-29 04:11:20 字数 1539 浏览 6 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

世界如花海般美丽 2024-12-06 04:11:20

这不是这样的 API。

您可以在扩展程序中使用 Google Analytics 来手动跟踪用户。

如果您不需要任何花哨的东西,只需要一定数量的安装和用户,可以使用我的扩展 扩展名,它会为您跟踪这些号码。

This is no such API.

You can use Google Analytics inside an extension to track users manually.

If you don't need anything fancy, just a number of installs and users, there is My Extensions extension, it will track those numbers for you.

甜尕妞 2024-12-06 04:11:20

将下面的代码片段复制并粘贴到以“.php”扩展名保存的 html 文档正文中的任意位置。

<?php

//URL of your extension
$url = "https://chrome.google.com/webstore/detail/ddldimidiliclngjipajmjjiakhbcohn";

//Get the nb of users
$file_string = file_get_contents($url);
preg_match('#>([0-9,]*) users</#i', $file_string, $users);
$nbusers = str_replace(",", "",$users[1]);

echo $nbusers; //Display the number of users

?>

Copy and paste the snippet below wherever you want in the body of a html document saved with a ".php" extension.

<?php

//URL of your extension
$url = "https://chrome.google.com/webstore/detail/ddldimidiliclngjipajmjjiakhbcohn";

//Get the nb of users
$file_string = file_get_contents($url);
preg_match('#>([0-9,]*) users</#i', $file_string, $users);
$nbusers = str_replace(",", "",$users[1]);

echo $nbusers; //Display the number of users

?>
与君绝 2024-12-06 04:11:20

您还可以使用跨域工具仅在客户端(至少在您这边)执行此操作。此代码片段将获取扩展程序的 Chrome 网上应用店页面上显示的用户数量(截至 2018 年 4 月 28 日最新):

var chromeExtensionWebstoreURL = 'https://chrome.google.com/webstore/detail/background-image-for-goog/ehohalpjnnlcmckljdflafjjahdgjpmh';

$.getJSON('http://www.whateverorigin.org/get?url=' + encodeURIComponent(chromeExtensionWebstoreURL) + '&callback=?', function(response){
    var numUsers = ((""+response.contents.match(/<span class="e-f-ih" title="([\d]*?) users">([\d]*?) users<\/span>/)).split(",")[2]);
    console.log(numUsers);
});

将来,Google 可能会更改用户计数范围的类名称,在这种情况下您只需要适当更新正则表达式即可。

You can also do this client-side only (at least on your end) by using a cross-domain tool. This snippet will grab the number of users displayed on the Chrome webstore page for an extension (up-to-date as of April 28, 2018):

var chromeExtensionWebstoreURL = 'https://chrome.google.com/webstore/detail/background-image-for-goog/ehohalpjnnlcmckljdflafjjahdgjpmh';

$.getJSON('http://www.whateverorigin.org/get?url=' + encodeURIComponent(chromeExtensionWebstoreURL) + '&callback=?', function(response){
    var numUsers = ((""+response.contents.match(/<span class="e-f-ih" title="([\d]*?) users">([\d]*?) users<\/span>/)).split(",")[2]);
    console.log(numUsers);
});

In the future, Google may change the class name of the user count span, in which case you just need to update the regex appropriately.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文