-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
35 lines (30 loc) · 846 Bytes
/
main.js
File metadata and controls
35 lines (30 loc) · 846 Bytes
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
const url = "https://www.espncricinfo.com/series/ipl-2020-21-1210595";
const request = require("request");
const cheerio = require("cheerio");
const AllMatchobj = require("./allmatch")
// Folder Creation ipl
const fs = require("fs");
const path = require("path");
const iplPath = path.join(__dirname, "ipl");
dirCreator(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");
let fullLink = "https://www.espncricinfo.com" + link;
AllMatchobj.gAlmatches(fullLink);
}
function dirCreator(filePath) {
if (fs.existsSync(filePath) == false) {
fs.mkdirSync(filePath);
}
}