A
A
aaklftw2019-12-04 18:54:14
Parsing
aaklftw, 2019-12-04 18:54:14

How to get the names of repositories on github using cheeriojs?

I need to get a link to a repository from the href attribute in the repository name.
I'm parsing repositories from the link https://github.com/search?q=vuejs
5de7d56d9126e911954898.png
Here is my code:

const rp = require('request-promise');
const $ = require('cheerio');
const url = 'https://github.com/search?q=vuejs';

rp(url)
.then(function (html) {
    //success!
    const vueUrls = [];
    for (let i = 0; i < 50; i++) {
        vueUrls.push($('.repo-list a', html)[i].attribs.href);
    }
    console.log(vueUrls);
})
.catch(function (err) {
    //handle error
});

I get all a's from the list of repositories, but I need to display only the one in the repository name

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FinGanapre, 2019-12-04
@FinGanapre

If I understand correctly what element we are talking about, then you should change the selector to ".repo-list av-align-middle"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question