-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom.js
More file actions
147 lines (124 loc) · 5.01 KB
/
random.js
File metadata and controls
147 lines (124 loc) · 5.01 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
const tres = 'https://tres-bien.com/new-arrivals?p=1'
const uniqloMShop = "https://www.uniqlo.com/us/en/men/new-arrivals"
const uniqloWShop = "https://www.uniqlo.com/us/en/women/new-arrivals"
const zaraWNewArrivals = "https://www.zara.com/ca/en/woman-new-in-l1180.html?v1=1881787"
const kollectionNewArrivals = "https://kollektion.ca/collections/furniture-lighting/products.json"
const stussyNewArrivals = "https://www.stussy.com/collections/new-arrivals/products.json"
const havenshop = 'https://shop.havenshop.com/collections/new-arrivals/products.json'
const doverstreet = 'https://shop.doverstreetmarket.com/collections/whats-new/products.json'
const lessonseven = 'https://lessoneseven.com/collections/latest-arrivals/products.json'
const braindead = 'https://wearebraindead.com/products.json'
// setMyShops(myShops =>
// myShops.map((shop) =>
// shop.name === event.currentTarget.value
// ? {
// ...shop,
// checked: !JSON.parse(shop.checked),
// isActive: !JSON.parse(shop.checked)
// } : shop
// )
// )
// const index = myShops.findIndex(shop => shop.name === event.currentTarget.value);
// const shopsCopy = [...myShops];
// shopsCopy[index].checked = !JSON.parse(shopsCopy[index].checked)
// shopsCopy[index].isActive = shopsCopy[index].checked
// setMyShops(shopsCopy)
//get new arrivals tres bien
const tresbien = () => {
axios(tres)
.then(res => {
const html = res.data
const $ = cheerio.load(html)
let products = []
$('.product-item-info', html).each(function () {
const title = $(this).find('a').text()
const url = $(this).find('a').attr('href')
const img = $(this).find('img').attr('srcset')
const price = $(this).find('.price-wrapper').attr('data-price-amount')
const product = {
title,
url,
img,
price,
store: 'tres-bien',
date: Date.now()
}
products.push(product)
})
run(products)
}).catch(error => console.log('error'))
}
const uniqloW = () => {
axios(uniqloWShop)
.then(res => {
const html = res.data
const $ = cheerio.load(html)
const products = []
$('.product-tile', html).each(function () {
// const title = $(this).find('a').text()
const brand = $(this).find('a').text()
const title = $(this).find('.link').text()
const price = $(this).find('.value').text().trim()
const url = "https://uniqlo.com" + $(this).find('a').attr('href')
const img = $(this).find('.tile-image').attr('src')
const product = {
brand: 'uniqlo',
title,
price,
url,
img,
store: 'uniqlo-womens',
date: Date.now()
}
products.push(product)
})
run(products)
}).catch(error => console.log('error uniqlow'))
}
const uniqloM = () => {
axios(uniqloMShop)
.then(res => {
const html = res.data
const $ = cheerio.load(html)
const products = []
$('.product-tile', html).each(function () {
// const title = $(this).find('a').text()
// const brand = $(this).find('a').text()
const title = $(this).find('.link').text()
const price = $(this).find('.value').text().trim()
const url = "https://uniqlo.com" + $(this).find('a').attr('href')
const img = $(this).find('.tile-image').attr('src')
const product = {
brand: 'uniqlo',
title,
price,
url,
img,
store: 'uniqlo-mens',
date: Date.now()
}
products.push(product)
})
run(products)
}).catch(error => console.log('erroruniqlom'))
}
// tresbien()
// uniqloW()
// uniqloM()
// getShopifyNewArrivals(stussyNewArrivals,"stussy");
// getShopifyNewArrivals(havenshop,"haven");
// getShopifyNewArrivals(kollectionNewArrivals,"kollektion")
// getShopifyNewArrivals(doverstreet,"DSM")
// getShopifyNewArrivals(lessonseven,"less 17")
// getShopifyNewArrivals(braindead, "brain dead")
// setInterval(() => {
// tresbien()
// uniqloW()
// uniqloM()
// getShopifyNewArrivals(stussyNewArrivals,"stussy");
// getShopifyNewArrivals(havenshop,"haven");
// getShopifyNewArrivals(kollectionNewArrivals,"kollektion")
// getShopifyNewArrivals(doverstreet,"DSM")
// getShopifyNewArrivals(lessonseven, "less 17")
// getShopifyNewArrivals(braindead, "brain dead")
// }, 10000 * 60 * 60);