-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
98 lines (86 loc) · 4.26 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
<title>Scraper Display</title>
<meta name="author" content="Nico Schiavone">
<meta content="Scraped items displayed as an HTML table">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css" integrity="sha384-EkHEUZ6lErauT712zSr0DZ2uuCmi3DoQj6ecNdHQXpMpFNGAQ48WjfXCE5n20W+R" crossorigin="anonymous">
<link rel="stylesheet" href="css/custom.css">
</head>
<body>
<div class="container-fluid">
<main class="row">
<div class="col">
<h1>Scraper Display</h1>
<p>Every item on Uniqlo's website (for adults at least) in a convenient format.</p>
<div id="table-container"></div>
</div>
</main>
<footer class="row">
<div class="col">
<hr>
<p class="text-right">Made by <a href="https://mesophil.github.io">Nico Schiavone</a>. Source available on <a href="https://github.com/mesophil/scrapy-pg">GitHub</a>. The CSV display is loosely based on the work of <a href="https://github.com/derekeder/csv-to-html-table">Derek Eder</a>
</p>
</div>
</footer>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/js/bootstrap.bundle.min.js" integrity="sha384-zDnhMsjVZfS3hiP7oCBRmfjkQC4fzxVxFhBx8Hkz2aZX8gEvA/jsP3eXRCvzTofP" crossorigin="anonymous"></script>
<script src="js/jquery.csv.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js" integrity="sha384-rgWRqC0OFPisxlUvl332tiM/qmaNxnlY46eksSZD84t+s2vZlqGeHrncwIRX7CGp" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js" integrity="sha384-uiSTMvD1kcI19sAHJDVf68medP9HA2E2PzGis9Efmfsdb8p9+mvbQNgFhzii1MEX" crossorigin="anonymous"></script>
<script src="js/csv_to_html_table.js"></script>
<script>
function format_link(link) {
if (link)
return "<a href='" + link + "' target='_blank'>" + link + "</a>";
else return "";
}
function format_product_link(id) {
if (id)
return "<a href='https://www.uniqlo.com/ca/en/products/" + id + "' target='_blank'>" + id + "</a>";
else return "";
}
function show_image(link) {
if (link)
return "<img src='" + link + "' alt='Image displaying an item of clothing' width='300'>"
else return "";
}
function format_price(price) {
if (price)
return "$" + price
else return "";
}
function format_desc(desc) {
if (desc)
return '<div id="desc">' + desc + '<div>'
else return "";
}
CsvToHtmlTable.init({
csv_path: "data/uniqlo_all_items.csv",
element: "table-container",
allow_download: true,
csv_options: {
separator: ",",
delimiter: '"'
},
datatables_options: {
paging: true,
dom: "lrtip",
},
custom_formatting: [ // this is 0 indexed
[2, format_desc], // make sure name isn't too long
[3, format_product_link], //change the id into a hyperlink
[4, show_image], // embed img
[5, format_price], // add a dollar sign to the price
[7, format_desc], // apply desc rules to composition
[8, format_desc], // make desc not be huge
[9, format_desc], // make sure washing info isn't too long
[10, format_link] // link the size chart (.html)
]
});
</script>
</body>
</html>