Skip to content

Instantly share code, notes, and snippets.

@petrosh
Last active July 15, 2017 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petrosh/cbd605d35b474b5b56558a2464d888dc to your computer and use it in GitHub Desktop.
Save petrosh/cbd605d35b474b5b56558a2464d888dc to your computer and use it in GitHub Desktop.
prova jquery
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('p').append($().jquery);
$.ajax({
url: "https://cors-anywhere.herokuapp.com/https://www.goodreads.com/search.xml?key=YGezY0bM4jFWGNHR9VAY0A&q=Ender%27s+Game",
dataType: "xml",
success: function(xml) {
data = [];
xmlDoc = $.parseXML( xml );
$xml = $( xmlDoc );
works = $(xml).find('work');
$(xml).find('work').each(function(i,r){
data.push({
'title': $(this).find("best_book title").text(),
'author': $(this).find("best_book author name").text(),
'thumb': $(this).find("best_book small_image_url").text(),
'ratings': $(this).find("ratings_count").text(),
'stars': $(this).find("average_rating").text(),
'reviews': $(this).find("text_reviews_count").text(),
'year': $(this).find("original_publications_year").text()
});
console.log(data);
});
}
});
});
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment