-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
27 lines (27 loc) · 888 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
let url = 'https://github.com/topics';
// const { html } = require("cheerio/lib/api/manipulation");
const request = require("request");
const cheerio = require("cheerio");
const getRepoPageHtml = require("./repoPage");
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 linkElem = $(".no-underline.d-flex.flex-column.flex-justify-center");
for (let i = 0; i < linkElem.length; i++){
let href = $(linkElem[i]).attr("href");
let topic = href.split("/").pop();
// console.log(href);
let fullLink = `https://github.com/${href}`;
getRepoPageHtml(fullLink, topic);
}
}