-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
28 lines (26 loc) · 818 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
let url = "https://github.com/topics";
const request = require("request");
const cheerio = require("cheerio");
const getReposPageHtml = require("./reposPage");
request(url, cb);
function cb(err, response, html) {
if (err) {
console.log(err);
} else if (response.statusCode == 404) {
console.log("page not found");
}
else {
// console.log(html);
getTopicLinks(html);
}
}
function getTopicLinks(html) {
let $ = cheerio.load(html);
let linkElemArr = $(".no-underline.d-flex.flex-column.flex-justify-center");
for (let i = 0; i < linkElemArr.length; i++) {
let href = $(linkElemArr[i]).attr("href");
let topic = href.split("/").pop();
let fullLink = `https://github.com/${href}`;
getReposPageHtml(fullLink, topic);
}
}