views:

60

answers:

1

Hey Everyone,

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);
+1  A: 

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.

Braveyard