-
Notifications
You must be signed in to change notification settings - Fork 3
/
winescrape.js
30 lines (26 loc) · 949 Bytes
/
winescrape.js
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
(function(){
var removeVarietal = function(title){
var wine_types = ['port', 'shiraz','merlot', 'sauvignon blanc', 'rosé', 'rose', 'cabernet sauvignon', 'red', 'zinfandel', 'syrah', 'malbec', 'riesling', 'pinot noir', 'cabernet franc', 'bordeaux', 'chardonnay'];
var wine_prefix = ['late harvest', 'old vine'];
var process_title = {};
$(wine_types).each(function(i,val){
if (title.indexOf(val) !== -1){
process_title['title'] = title.replace(val,'');
process_title['varietal'] = val;
}
});
return process_title;
}
console.log('title,year,type,rating');
$('.wine_list_item').each(function(i,ele){
var title = $(ele).find('.description a').html();
var rating = $(ele).find('.mw_buttons input').val();
if (title && rating && rating > 0){
title = title.toLowerCase();
var process_title = removeVarietal(title);
console.log(title.replace(/\d+/, '').trim() + ','
+ title.replace(/[^\d]+/, '')+','
+rating );
}
});
})();