0
我在我的HTML文件中有這個Java腳本....我有一個關鍵字搜索我的網頁,我想通過關鍵字搜索到API。這是我目前擁有的:不確定我出錯的地方,它沒有產生任何搜索結果。谷歌新聞Api自定義搜索
,我在代碼中有
CNN
,這是我的搜索變量應該傳遞...
<script type="text/javascript">
google.load('search', '1');
function OnLoad()
{
var customSearchControl = new google.search.CustomSearchControl('CNN');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_
CSE_RESULTSET);
customSearchControl.draw('cse');
customSearchControl.execute("$q");
}
google.setOnLoadCallback(OnLoad);
// tell the searcher to draw itself and tell it where to attach
// create a drawOptions object
var drawOptions = new google.search.DrawOptions();
// tell the searcher to draw itself in tabbed mode
drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
searchControl.draw(document.getElementById("content"),drawOptions);
searchControl.addSearcher(new google.search.NewsSearch());
}
google.setOnLoadCallback(OnLoad);
</script>