Skip to content

Commit 5230f43

Browse files
author
hamzabourak
committed
first commit
0 parents  commit 5230f43

File tree

4 files changed

+767
-0
lines changed

4 files changed

+767
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/node_modules

index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const fetch = require('node-fetch');
2+
const jsdom = require("jsdom");
3+
const { JSDOM } = jsdom;
4+
const igraalUrl = "https://fr.igraal.com/ajax/category-merchants/informatique/1";
5+
6+
const vendorsInfo = {};
7+
8+
async function crawl(vendorName, url) {
9+
var res =
10+
await
11+
fetch(url)
12+
.then(res => res.text());
13+
14+
var dom = new JSDOM(res);
15+
var merchants = dom.window.document.querySelectorAll("div.widget-merchant-small--details");
16+
vendorsInfo[vendorName] = [];
17+
for (var i = 0; i < merchants.length; i++) {
18+
var m = merchants[i];
19+
var merchant = m.querySelector("h2").innerHTML;
20+
var cashBackPercent = m.querySelector(".cashback_rate").innerHTML;
21+
vendorsInfo[vendorName].push({
22+
merchant,
23+
cashBackPercent,
24+
});
25+
}
26+
console.log(JSON.stringify(vendorsInfo));
27+
}
28+
29+
crawl("igraal", igraalUrl);

0 commit comments

Comments
 (0)