Skip to content

Instantly share code, notes, and snippets.

@yangfch3
Last active March 6, 2020 15:07
Show Gist options
  • Save yangfch3/5b3ee7efd535ab63cd56 to your computer and use it in GitHub Desktop.
Save yangfch3/5b3ee7efd535ab63cd56 to your computer and use it in GitHub Desktop.
拉取你的 github star 列表
const fs = require('fs'),
child_exe = require('child_process');
let page = 1,
perPage = 20;
function autoCrawl() {
child_exe.exec(`curl https://api.github.com/users/yangfch3/starred?page=${page} --silent`, function (err, stdout, stderr) {
let data = stdout,
dataArr = JSON.parse(data),
output = '';
if (dataArr.length === 0) {
return;
}
console.log('本页第一个 item: ' + dataArr[0].full_name);
for (let meta of dataArr) {
output += '[' + meta.full_name + ']' + '(' + meta.html_url + ')' + '\n' + ': ' + meta.description + '\n\n';
}
fs.appendFileSync('output.md', output);
if (dataArr.length < perPage) {
console.log(`全部拉取完毕!`);
return;
} else {
console.log(`第 ${page} 页拉取成功;`);
page++;
autoCrawl();
}
})
}
autoCrawl();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment