在Google API WebSearch结果标题中停用突出显示 [英] Disable Highlighting in Google API WebSearch Result Title

查看:80
本文介绍了在Google API WebSearch结果标题中停用突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Google Web Search API,但搜索关键字突然显示 - 在返回对象的title属性中带有b标签。



我想过 webSearchControl.setNoHtmlGeneration(); 可以工作但不会改变任何东西。

我知道如何处理其他方式,但谷歌API有没有什么方法可以避免响应中的任何HTML事情?



谢谢。



顺便让我粘贴我的代码在这里进一步的信息:

  google.load(search,1,{ nocss:true}); 

函数OnLoad(){
//创建搜索控件
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);



函数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);


解决方案

我刚刚找到解决方案:



它应该是这样的:

  $(#googleSearch) .html($(#googleSearch)。html()+'< br />< a href ='+ results [0] .url +'target =blank>'+ results [0] .titleNoFormatting +'< / a>'); 
}

所以基本上 .titleNoFormatting 解决这个问题。


I've been using Google Web Search API but the searched keyword is coming highlighted - with b tag- in the title property of the return object.

I thought webSearchControl.setNoHtmlGeneration(); could work but didn't change anything.

I know how to deal with other ways but is there any ways Google API provides to avoid any html thing in the response?

Thanks.

By the way let me paste my code here for further info :

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);

解决方案

I've just found the solution:

It should be something like this :

$("#googleSearch").html($("#googleSearch").html() + '<br/><a href=' + results[0].url + ' target="blank">' + results[0].titleNoFormatting + '</a>');
}

So basically .titleNoFormatting solves the problem here.

这篇关于在Google API WebSearch结果标题中停用突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆