我一直在使用 Google Web Search API,但搜索到的关键字在返回对象的 title 属性中突出显示 - 带有 b 标记。
我认为webSearchControl.setNoHtmlGeneration();
可以工作,但没有改变任何东西。
我知道如何处理其他方式,但是 Google API 有没有提供任何方法来避免响应中的任何 html 内容?
谢谢。
顺便说一下,让我在这里粘贴我的代码以获取更多信息:
google.load("search", "1", { "nocss": true });
function OnLoad() {
// Create a search control
var webSearchControl = new google.search.WebSearch();
webSearchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
webSearchControl.setNoHtmlGeneration();
webSearchControl.setSearchCompleteCallback(this, OnCompleted, [webSearchControl]);
webSearchControl.execute("programming");
setInterval(function () {
webSearchControl.execute("Programming");
}, 3000);
}
function OnCompleted(webSearchControl) {
var results = webSearchControl.results;
$("#googleSearch").html($("#googleSearch").html() + '<br/><a href=' + results[0].url + ' target="blank">' + results[0].title + '</a>');
}
google.setOnLoadCallback(OnLoad);