我在我的网站上做了一个搜索引擎。现在,如果我转到搜索页面,一切正常。我想直接通过chrome中的搜索框进行搜索。所以我进入设置并设置了搜索引擎。问题是chrome没有显示对我的搜索引擎的建议。但是我不知道如何给铬化建议的字符串。
您正在寻找"OpenSearch"。 具体来说,您需要:
-
在 HTML 或 HTTP 标头中提供指向打开的搜索描述文档的链接
Link
:<link rel="search" type="application/opensearchdescription+xml" href="http://example.com/content-search.xml" title="Content search" />
-
包括
rel=suggestions
的Url
元素,例如:<Url type="application/json" rel="suggestions" template="http://example.com/suggest?q={searchTerms}" />
-
使用规范中描述的嵌套数组格式的建议列表响应对该 URL 的请求:
["sea", # User's search term ["sears", # Suggested search terms "search engines", "search engine", "search", "sears.com", "seattle times"], ["7,390,000 results", # Suggested search descriptions "17,900,000 results", "25,700,000 results", "1,220,000,000 results", "1 result", "17,600,000 results"], ["http://example.com?q=sears", # Links for suggested searches (optional) "http://example.com?q=search+engines", "http://example.com?q=search+engine", "http://example.com?q=search", "http://example.com?q=sears.com", "http://example.com?q=seattle+times"]]
另请参阅:https://github.com/dewitt/opensearch