-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
67 lines (58 loc) · 1.32 KB
/
index.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import * as dotenv from "dotenv";
dotenv.config();
import express from "express";
import cron from "node-cron";
import ScrapData from "./scrapKenNews.js";
import scrapFootball from "./scrapFootball.js";
import scrapIntNews from "./scrapIntNews.js";
const app = express();
const port = 3001;
cron.schedule(
"*/30 * * * *",
() => {
try {
console.log("Running a web scrap of tuko news");
ScrapData(
"https://www.tuko.co.ke/",
"article a",
"article h1",
"article .post__content",
"article .article-image .article-image__picture"
);
} catch (err) {
console.log(err)
}
},
{
scheduled: true,
timezone: "Africa/Nairobi",
}
);
//internationa news
cron.schedule(
"*/40 * * * *",
() => {
try {
console.log("Running a web scrap of NBC.NEWS");
scrapIntNews(
"https://www.nbcnews.com/latest-stories/",
".tease-card__info h2 a",
"header div h1",
".article-body .article-body__content",
".article-hero__main .article-hero__main-image img"
);
} catch (err) {
console.log(err)
}
},
{
scheduled: true,
timezone: "Africa/Nairobi",
}
);
app.get('/share', (req, res) =>{
console.log(req)
})
app.listen(port, () => {
console.log(`verixr scraper listening on port ${port}`);
});