2010-03-05 3 views
0

J'ai utilisé l'API Google Web Search, mais le mot clé recherché est mis en surbrillance - avec b tag - dans la propriété title de l'objet de retour.Désactiver la surbrillance dans l'API Google Résultat de la recherche sur le Web Titre

Je pensais que webSearchControl.setNoHtmlGeneration(); pouvait fonctionner mais n'a rien changé.

Je sais comment faire face à d'autres façons, mais y a-t-il des moyens que l'API Google fournit pour éviter toute chose html dans la réponse?

Merci.

D'ailleurs permettez-moi de coller mon code ici pour plus d'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); 

Répondre

1

Je viens de trouver la solution:

Il devrait être quelque chose comme ceci:

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

Donc, fondamentalement, .titleNoFormatting résout le problème ici.

Questions connexes