Skip to content

Commit e1d711c

Browse files
author
code-reaper08
committed
need some fixes looping
1 parent 3ac7a47 commit e1d711c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

scrape.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
const request = require('request');
22
const cheerio = require('cheerio');
33

4-
request('https://github.com/whatwg/html/blob/main/README.md', (error,response,html) =>{
4+
request('https://github.com/code-reaper08/markdownpedia/blob/main/README.md', (error,response,html) =>{
55
if(!error && response.statusCode == 200) {
66
const $ = cheerio.load(html);
77
const linkObjects = $('#readme > article').children().find('a');
88
const links = [];
99
linkObjects.each((index, element) => {
1010
links.push({
11-
text: $(element).text(),
11+
// text: $(element).text(),
1212
href: $(element).attr('href'),
1313
});
1414
});
15-
// const len = links.length;
15+
const len = links.length;
1616
// console.log(len);
17-
console.log(links);
17+
// console.log(links);
18+
// var arrayLength = myStringArray.length;
19+
for (let i = 0; i <len ; i++) {
20+
console.log("loop running")
21+
console.log(links[i]);
22+
//Do something
23+
}
1824
// console.log(links[8]);
1925
}
2026
});

0 commit comments

Comments
 (0)