const $ = require('cheerio');
const axios = require('axios');
const fakeUa = require('fake-useragent');
const getPageData = async (url, param) => {
try {
return response = await axios.get(url, param = {});
} catch (err) {
console.log(err);
}
}
(async () => {
try {
let { data } = await getPageData('https://github.com/search?q=vuejs', {
headers: {
'User-Agent': fakeUa()
}
});
let links = new Set();
$('.repo-list a.v-align-middle', data).each((idx, elem) => {
links.add(`https://github.com${ $(elem).attr('href') }`);
});
console.log(links);
} catch(err) {
console.log(err);
}
})();