大家都知道通过Google Ajax Search Api接口,能引用Google搜索功能,打造自己的站内搜索,但自己实在是不知道API是啥东西,而且对Ajax也一无所知,要怎么办呢?下面我介绍一种白痴化的方法通过Google Custom Search同样达到Google站内搜索。
首先来到Google Custom Search页面申请属于你自己的Custom Search.
直接点击图中的”Creat a Search Engine”开始申请。
按照提示输入一些基本信息,在”Site to search”选项框里输入你的站点,注意去掉下面”Alaso include all site
linked to from these pages”的选钩,如果选中这项的话,它同样会从连接到你站点的页面里面搜索,当然你如果想这样的话,你可以选中这项。
完成申请后,点击左侧的”My search engines”,这时你就会看到你刚刚申请的Custom search,点击选项中的”control panel”,来到控制面板,点击导航中的”code”来获取代码。
点击下面的”Search box and search results code for you website”,在”Specify the URL of the page on your site where you want to the search results to appear”选项框输入你想要显示搜索结果的页面。往下面看,你会发现有两段代码。上面的代码时显示搜索框的,你可以把它放到你页面任何想显示搜索框的位置。而下面的一段代码是要放置到你显示搜索结果页面中的,也就你你刚刚指定的”Specify the URL of the [...]