J'utilise la simple API Google pour afficher les résultats de la recherche. Je voudrais obtenir la valeur href d'un lien sur mouseover ou cliquer. Ce n'est vraiment pas important quelle est la saveur de javascript utilisée, j'ai juste besoin d'obtenir la valeur href sélectionnée par l'utilisateur de la recherche rendue.Comment obtenir les résultats de l'API de recherche Google Valeurs href avec jquery
(je besoin de ce que j'ai un webservice qui permet aux utilisateurs d'enregistrer des liens qu'ils trouvent d'intérêt.)
Je suis horrible script côté client pour que je puisse vraiment utiliser une main. Avec l'exemple ici, j'utilise l'exemple de l'API de recherche Google AJAX par défaut.
To visually explain I have posted this image. (ne peut pas joindre)
J'ai utilisé le lien - How to get href value using jQuery? - pour référence simple, sans succès. Je crois que c'est en raison de l'ordre de rendu de façon/page que les résultats de recherche de google sont montrés.
La source html pré rendu est la suivante:
<!--
copyright (c) 2009 Google inc.
You are free to copy and use this sample.
License can be found here: code.google.com/apis/ajaxsearch/faq/#license
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google AJAX Search API Sample</title>
<script src="http://www.google.com/jsapi?key=AIzaSyA5m1Nc8ws2BbmPRwKu5gFradvD_hgq6G0" type="text/javascript"></script>
<script type="text/javascript">
/*
* How to do a search that returns the max number of results per page.
*/
google.load('search', '1');
function OnLoad() {
// create a search control
var searchControl = new google.search.SearchControl();
// Set the Search Control to get the most number of results
searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
// Create 2 searchers and add them to the control
searchControl.addSearcher(new google.search.WebSearch());
searchControl.addSearcher(new google.search.BlogSearch());
// Set the options to draw the control in tabbed mode
var drawOptions = new google.search.DrawOptions();
drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
// Draw the control onto the page
searchControl.draw(document.getElementById("content"), drawOptions);
// Search!
searchControl.execute("Subaru STI");
}
google.setOnLoadCallback(OnLoad);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="content">Loading...</div>
</body>
</html>
The relevent rendered result html source is as follows:
<div class="gs-webResult gs-result">
<div class="gs-title">
<a class="gs-title" href="http://en.wikipedia.org/wiki/Subaru_Impreza_WRX_STI" target="_blank">
<b>Subaru</b> Impreza WRX <b>STI</b> - Wikipedia, the free encyclopedia</a></div>
Si quelqu'un peut me diriger dans la bonne direction, je voudrais vraiment l'apprécier. Merci à un million, Dave
Merci. J'ai fini par utiliser silverlight pour rendre la sortie. Votre exemple fonctionne pour l'API Google dépréciée en utilisant Jquery. – DaveCS
Assez sûr que la fonction 'live' a été depuis obsolète. IIRC, il a été intégré dans 'on' via un paramètre supplémentaire. – Carcigenicate