-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
36 lines (34 loc) · 987 Bytes
/
main.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
const url = "https://www.espncricinfo.com/series/ipl-2020-21-1210595";
const fs = require("fs");
const path = require("path");
// Venue date opponent result runs balls fours sixes sr
const request = require("request");
const cheerio = require("cheerio");
const AllMatcgObj = require("./Allmatch");
// home page
const iplPath = path.join(__dirname, "ipl");
dirCreater(iplPath);
request(url, cb);
function cb(err, response, html) {
if (err) {
console.log(err);
} else {
// console.log(html);
extractLink(html);
}
}
function extractLink(html) {
let $ = cheerio.load(html);
let anchorElem = $("a[data-hover='View All Results']");
//
let link = anchorElem.attr("href");
// console.log(link);
let fullLink = "https://www.espncricinfo.com" + link;
console.log(fullLink);
AllMatcgObj.gAlmatches(fullLink);
}
function dirCreater(filePath) {
if (fs.existsSync(filePath) == false) {
fs.mkdirSync(filePath);
}
}