从其他评论网站获取餐厅评论

发布于 2024-11-18 01:23:16 字数 236 浏览 3 评论 0原文

我正在使用 php 构建一个餐厅评论网站。我想知道如何显示其他评论网站的评论。例如,请查看此链接,了解 Google 如何正在从其他网站获取评论。单击后,您将进入他们的评论网站。

任何帮助将不胜感激。谢谢

I am building a restaurant review site using php. I wanted to know how to show reviews from other reviews sites. For example check this link to see how google is picking up reviews from other sites. When clicked on, it takes you to their review site.

Any help will be appreciated. Thanks

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

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

发布评论

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

评论(3

甚是思念 2024-11-25 01:23:16

首先,列出您想要从中提取评论的网站。其次,通读这些网站,看看它们是否有开发人员部分以及是否公开公共 API。如果他们这样做,请四处看看他们是否有任何 php 客户端库,您可以使用它们从您的 php 站点访问他们的 API。如果他们确实有 API,但没有可用的客户端库,请通过创建客户端库并将其作为开源共享来为社区做出贡献。 :)

另外,他们可能有评论的 RSS 提要,您可以轻松地在您的网站上使用它,所以也请检查一下。

First, make a list of the sites that you want to pull reviews from. Second, read through those sites and see if they have a developer section and if they expose a public API. If they do, look around to see if they have any client libraries for php which you can use to access their API from your php site. If they do have an API but there are no client libraries available, contribute to the community by creating a client library and sharing it as open source. :)

Also, it may be possible that they have an RSS feed of their reviews that you can consume easily of your site, so check that out too.

土豪 2024-11-25 01:23:16

可能会发现其他网站已为此与 Google 合作,但我会使用 cURL 来获取您想要的信息。

我建议您从这里开始使用cURL,然后使用查看此处提取您所在的部分寻找 为了。

编辑:第二个链接的相关部分是,

preg_match_all("/<div>.+<\/div>/", $page, $matches);
print_r($matches);

它的作用是获取您正在查找的内容,然后显示它,您可能需要使用您要查找的内容定义唯一元素然而,这可能意味着每个网站都有单独的规则。

我希望这对你有帮助。

You will probably find the other sites have partnered with Google for this, however I would be using cURL to get the information you want.

I would suggest you start here with cURL, then have a look here to extract the portion you're looking for.

Edit: the section of the second link that is relevant is

preg_match_all("/<div>.+<\/div>/", $page, $matches);
print_r($matches);

What this is doing is getting the content you're looking for and then displaying it, you will probably need to define the unique elements with the content you want however, this could mean a separate rule for each website.

I hope this helps for you.

倾城花音 2024-11-25 01:23:16

我认为谷歌通过站点地图找到新闻、博客、评论和类似的东西,网络管理员将其作为 sitemap.xml 引入谷歌。
为此,您必须获取您想要获取评论的页面内容(通过 CURL 或类似的方式获取远程文件)并通过 HTML 正则表达式获取评论

I think google find News, Blog , Reviews and something like that by site map what web administrators introduce to google as sitemap.xml .
To do this you must get page content what you want to fetch it's reviews ( By CURL or something like that to get remote file ) and fetch reviews by regular expression of HTML

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