From d565ebaedc7b33a7b0b0cc446902d66eb7129812 Mon Sep 17 00:00:00 2001 From: isboyjc <214930661@qq.com> Date: Fri, 2 Aug 2024 02:23:21 +0800 Subject: [PATCH] =?UTF-8?q?test=E2=9C=85:=20test=20lang=20json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/index.js | 33 ++++++++++++++++++--------------- script/parse.js | 11 +++++++---- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/script/index.js b/script/index.js index eff29a4a98f1..213dec527d8d 100644 --- a/script/index.js +++ b/script/index.js @@ -41,19 +41,22 @@ function delay(ms) { } (async () => { - await run('daily', 'all') - await run('weekly', 'all') - await run('monthly', 'all') - - let languages = readFileSync(path.resolve(__dirname, DATA_BASE_URL, 'languages.json'), 'utf8'); - languages = JSON.parse(languages); - - console.log("Number of languages: ", languages.length) - - for(const langObj of languages){ - await delay(5 * 60) - await run('daily', convertToSlug(langObj.name)) - await run('weekly', convertToSlug(langObj.name)) - await run('monthly', convertToSlug(langObj.name)) - } + // await run('daily', 'all') + // await run('weekly', 'all') + // await run('monthly', 'all') + + // let languages = readFileSync(path.resolve(__dirname, DATA_BASE_URL, 'languages.json'), 'utf8'); + // languages = JSON.parse(languages); + + // console.log("Number of languages: ", languages.length) + + // for(const langObj of languages){ + // await delay(5 * 60) + // await run('daily', convertToSlug(langObj.name)) + // await run('weekly', convertToSlug(langObj.name)) + // await run('monthly', convertToSlug(langObj.name)) + // } + await run('daily', 'json') + await run('weekly', 'json') + await run('monthly', 'json') })(); \ No newline at end of file diff --git a/script/parse.js b/script/parse.js index 5dab669e70df..6aa7dc76aa27 100644 --- a/script/parse.js +++ b/script/parse.js @@ -15,12 +15,15 @@ function parse(data){ const stars = $(elm).find(`a[href=${url + '/stargazers'}]`).text().replace(/\n/g, '').trim() const forks = $(elm).find(`a[href=${url + '/forks'}]`).text().replace(/\n/g, '').trim() const addStars = $(elm).find('span').last().text().match(/\d+/g)[0] - const contributors = $(elm).find(`a[data-hovercard-type="user"]`).map((_ ,user) => { - const name = $(user).find('.avatar').attr('alt').replace(/^@/, '') + const contributors = $(elm).find(`a[data-hovercard-type="user"] .avatar.avatar-user`).map((_ ,user) => { + const name = $(user).attr('alt').replace(/^@/, '') + // const url = BASE_URL + $(user).attr('href') + const url = `${BASE_URL}/${name}` + // console.log(url) return { - avatar: $(user).find('.avatar.avatar-user').attr('src'), + avatar: $(user).attr('src'), name, - url: `https://github.com/${name}` + url } }).get(); const item = {