无为清净楼资源网 Design By www.qnjia.com

Google AJAX 搜索 API
文档:http://code.google.com/intl/zh-CN/apis/websearch/docs/

复制代码 代码如下:
<!DOCTYPE html>
<html>
<head>
<title>Google AJAX 搜索 API</title>
<style type="text/css">
#searchcontrol .gsc-control
{
width: 100%;
}
#searchcontrol .gsc-result-cnblogs .gs-title
{
color:Red;
}
</style>
<script src="/UploadFiles/2021-04-02/jsapi?key=ABQIAAAAWUT8aaIj9mtqQa087LjVOhTPB5B7LRDljl2Cr4-
JwBNft1mFrRRmR1RoYEUCZCj0dtS2gIc8Al4-VA">type="text/javascript"></script>
<script language="Javascript" type="text/javascript">
google.load("search", "1");

function OnLoad() {
//搜索设置
var options = new google.search.SearcherOptions();
//当搜索结果为空时显示内容
options.setNoResultsString('查询结果为空!');

//搜索控件实例化
var searchControl = new google.search.SearchControl();
//每次显示8个搜索结果(取值范围:1-8)
searchControl.setResultSetSize(8);

//网页搜索
var siteCnblogs = new google.search.WebSearch();
//标头
siteCnblogs.setUserDefinedLabel("");
//样式后缀名
siteCnblogs.setUserDefinedClassSuffix("jb51");
//站点限制
siteCnblogs.setSiteRestriction("jb51.net");
searchControl.addSearcher(siteCnblogs, options);

//局部搜索
var siteZjfree = new google.search.WebSearch();
siteZjfree.setUserDefinedLabel("素材搜索");
siteZjfree.setSiteRestriction("sc.jb51.net");
searchControl.addSearcher(siteZjfree, options);

//全网搜索
searchControl.addSearcher(new google.search.WebSearch(), options);

//添加博客搜索
searchControl.addSearcher(new google.search.BlogSearch(), options);

//添加视频搜索
searchControl.addSearcher(new google.search.VideoSearch(), options);

//添加新闻搜索
searchControl.addSearcher(new google.search.NewsSearch(), options);

//添加图片搜索
searchControl.addSearcher(new google.search.ImageSearch(), options);

//添加本地地图搜索
var localSearch = new google.search.LocalSearch();
//地图中心标记 测试时可使用“大雁塔”
localSearch.setCenterPoint("西安,钟楼");
searchControl.addSearcher(localSearch, options);

//绘制搜索
var drawOptions = new google.search.DrawOptions();
drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
searchControl.draw(document.getElementById("searchcontrol"), drawOptions);

//执行搜索查询
searchControl.execute("google api");
}

//框架加载完成后调用
google.setOnLoadCallback(OnLoad);
</script>
</head>
<body>
<div id="searchcontrol">
加载中...
</div>
</body>
</html>

标签:
AJAX,搜索,API

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com