-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
36 lines (34 loc) · 1.01 KB
/
main.js
File metadata and controls
36 lines (34 loc) · 1.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
let url = "https://www.espncricinfo.com/series/ipl-2020-21-1210595";
const request = require('request');
const cheerio = require('cheerio');
const fs = require('fs');
const path = require('path');
const allmatchobj = require('./allmatch');
const { fstat } = require('fs');
const iplPath= path.join(__dirname,"ipl");
dirCreater(iplPath);
request(url, cb);
function cb(err, response, html) {
if (err) {
console.log("Error");
}
else {
// console.log(html);
extractlink(html);
}
}
function extractlink(html) {
let $ = cheerio.load(html);//read
let anchor = $("a[data-hover='View All Results']");// double quote double quote issue so use ingle quote
// console.log(anchor.text());
let href = $(anchor).attr("href");
// console.log(href);
let fullLink = "https://www.espncricinfo.com" + href;
// console.log(fullLink);
allmatchobj.getAllMatch(fullLink);
}
function dirCreater(filepath){
if(fs.existsSync(filepath)==false){
fs.mkdirSync(filepath);
}
}