-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetAllMatchLinks.js
39 lines (27 loc) · 962 Bytes
/
getAllMatchLinks.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
31
32
33
34
35
36
37
38
39
const request = require("request");
const cheerio = require("cheerio");
const { processScoreCard } = require("./scoreCard");
function getAllMatches(fullLink) {
request(fullLink, function (error, response, html) {
if (error) {
console.log(error);
} else {
getExtractAllLinks(html);
}
});
}
function getExtractAllLinks(html) {
let $ = cheerio.load(html);
let anchorElm = $(".ds-flex .ds-grow.ds-px-4.ds-border-r.ds-border-line-default-translucent>a");
let link = null;
for (let i = 0; i < anchorElm.length; i++) {
link = $(anchorElm[i]).attr("href");
let fullLink = "https://www.espncricinfo.com/" + link;
// console.log(fullLink);
// call the scoreCard function to get all match scrore detials using these match links :
processScoreCard(fullLink); // each time one macth link passed out of 60 match
}
}
module.exports = {
getAllMatches,
};