-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreposPage.js
35 lines (34 loc) · 1.13 KB
/
reposPage.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
const request = require("request");
const cheerio = require("cheerio");
const getIssuesPageHtml = require("./issue");
function getReposPageHtml(url, topic) {
request(url, cb);
function cb(err, response, html) {
if (err) {
console.log(err);
} else if (response.statusCode == 404) {
console.log("page not found");
}
else {
getReposLink(html);
// console.log(html);
}
}
function getReposLink(html) {
// cheerio
let $ = cheerio.load(html);
let headingsArr = $(".f3.color-fg-muted.text-normal.lh-condensed");
console.log(topic);
for (let i = 0; i < 8; i++) {
let twoAnchors = $(headingsArr[i]).find("a");
let link = $(twoAnchors[1]).attr("href");
// console.log(link);
let fullLink = `https://github.com${link}/issues`;
// console.log(fullLink);
let repoName = link.split("/").pop();
getIssuesPageHtml(fullLink, topic,repoName);
}
console.log("````````````````````````````");
}
}
module.exports = getReposPageHtml;