-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
71 lines (64 loc) · 2.24 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!doctype html>
<head>
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/superhero/bootstrap.min.css">
</head>
<body>
<header style="text-align: right; font-size: 10px;">Demo of Yahoo YQL scraping.  Created by Jeffrey Scholz.  Public Domain 2016.</header>
<div align="center">
<h1>Amazon Scraper</h1>
<div class="form-group" style="width:500px;">
<div class="input-group">
<input class="form-control" type="text" id="search-field">
<span class="input-group-btn">
<button class="btn btn-default" type="button" id="search-button">Search</button>
</span>
</div>
</div>
<!-- display this while waiting for the server to compile information -->
<div id="loading-text" style="display: none;">
<h3>loading...</h3>
</div>
</div>
<!-- content will be attached to this div -->
</div>
<ul id="amazon-results" class="list-group"></ul>
</div>
<script>
$(document).ready(function() {
$("#search-button").click(searchButtonClicked);
});
function searchButtonClicked() {
var searchValue = $("#search-field").val();
$.ajax({
url: '/ajax',
data: {
query: searchValue
},
beforeSend: function() {
$("#amazon-results").empty();
$("#loading-text").show();
},
complete: function() {
$("#loading-text").hide();
},
success: function(data, status, xhr) {
populateResults(data);
}
});
}
function populateResults(data) {
for (var i = 0; i < data.amazonItems.length; i ++) {
var item = data.amazonItems[i];
$("#amazon-results").append(
'<li class="list-group-item well">' +
'<h3>' + item.title + '</h3>' +
'<img src=' + item.imgURL + ' height="250" width="250"></img>' +
'<p>' + item.price + '</p>' +
'</li>'
);
}
}
</script>
</body>