Google使用什么算法将Chrome浏览器的地址栏作为许多网站的默认搜索栏? [英] What algorithm does google use to make Chrome browser's address bar to act as a default search bar for many websites?

查看:222
本文介绍了Google使用什么算法将Chrome浏览器的地址栏作为许多网站的默认搜索栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想知道Google使用哪种算法来使Chrome浏览器的地址栏充当许多网站(例如SO,Quroa等)的默认搜索栏,但不适用于Facebook,metastackoverflow等。

例如,如果你想在stackoverflow中搜索一个主题,你可以用chorme这样做。


$ b



搜索结果会直接将您带到计算器页面。即





如果您在chrome的地址栏中选择搜索 quora.com ,也会发生同样的情况。但是,如果您在地址栏和许多其他有搜索栏的网站中搜索 facebook.com ,则不会发生这种情况。



这是怎么发生的?谷歌使用什么算法来实现这一点?



希望我对我的问题很清楚?任何帮助将不胜感激。

解决方案

此功能由称为OpenSearch的功能提供支持。它允许您指定在搜索网站时应如何形成查询。您可以在这里阅读文档: http://www.opensearch.org/Home



例如,StackOverflow的HTML源代码中包含以下内容:

 < link rel =search type =application / opensearchdescription + xmltitle =Stack Overflowhref =/ opensearch.xml> 

如果您打开文件/opensearch.xml,您可以看到以下内容:

 <?xml version =1.0encoding =UTF-8?> 
< OpenSearchDescription xmlns =http://a9.com/-/spec/opensearch/1.1/xmlns:moz =http://www.mozilla.org/2006/browser/search/> ;
< ShortName>堆栈溢出< / ShortName>
<说明>搜索堆栈溢出:针对专业和爱好者程序员的Q& A< /说明>
< InputEncoding> UTF-8< / InputEncoding>
< Image width =16height =16type =image / x-icon> http://sstatic.net/stackoverflow/img/favicon.ico< / Image>
< Url type =text / htmlmethod =gettemplate =http://stackoverflow.com/search?q={searchTerms}>< / Url>
< / OpenSearchDescription>

最重要的部分是在第7行指定搜索字词串的行。


I am wondering what algorithm does google use to make chrome browser's address bar to act as a default search bar for many websites like SO, Quroa etc. but not for facebook, metastackoverflow etc..

For example if you want to search for a topic in stackoverflow, you can do like this in chorme.

And the search results will directly take you to the stackoverflow page. i.e.

The same will happen if you choose to search quora.com also in chrome's address bar. But this won't happen if you search like facebook.com in the address bar and many other websites that have a search bar.

How is this happening? What algorithm does google use to make this happen?

Hope I am clear with my question? Any help would be appreciated.

解决方案

This feature is powered by what is known as OpenSearch. It allows you to specify how queries are supposed to be formed when searching a website. You can read the documentation here: http://www.opensearch.org/Home

For example, StackOverflow has the following in their HTML source code:

<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml">

If you then open the file /opensearch.xml you can see the following:

<?xml version="1.0" encoding="UTF-8" ?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
  <ShortName>Stack Overflow</ShortName>
  <Description>Search Stack Overflow: Q&amp;A for professional and enthusiast programmers</Description>
  <InputEncoding>UTF-8</InputEncoding>
  <Image width="16" height="16" type="image/x-icon">http://sstatic.net/stackoverflow/img/favicon.ico</Image>
  <Url type="text/html" method="get" template="http://stackoverflow.com/search?q={searchTerms}"></Url>
</OpenSearchDescription>

The most important part is the line that specifies the search term string in line 7.

这篇关于Google使用什么算法将Chrome浏览器的地址栏作为许多网站的默认搜索栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆