@udayax
Frotend @Sensibull - India's Largest Options Trading Platform | Full Stack Web Developer | React ❄ | JavaScript ⚡ TypeScript | MERN
Nothing here yet.
Snippet to scrap data from Github profile const repos = document.querySelectorAll('#user-list-repositories > div') // this selects all HTML nodes of the repo const requiredData = [] // Process required data from the HTML node repos.forEach((repo) => { const children = repo.children const name = children[0].innerText const description = children[2] && children[2].innerText if (!children[3]) return const details = children[3].querySelectorAll('a') const starts = details[0].innerText const forks = details[1].innerText requiredData.push({ name, description, starts, forks }) }) console.log(requiredData) Process those data into the required Markdown format const fs = require('fs') let data = [{},{},{},{},...] /* Array of data in this format {"name":"markodenic / web-development-resources", "description":"Awesome Web Development Resources.", "stars":" 4,310 ", "forks":" 773 "} */ data.forEach((repo) => { repo.name = `${repo.name.replace(' / ', '/')}` repo.link = `https://github.com/${repo.name.replace(' / ', '/')}` repo.stars = (parseInt(repo.stars.replace(",", ""))) repo.forks = (parseInt(repo.forks.replace(",", ""))) }) // Sort repos based on Github starts data = data.sort((a, b) => b.stars - a.stars) // Util to convert 1223 -> 1.2k const util = (val) => Math.round(val / 100) / 10 let result = '' // combine all data with formatting data.forEach((repo, i) => { let text = (`${repo.name.split('/')[1]}`) let final = `### ${i + 1} [${text}](${repo.link})` const detail = `⭐ ${util(repo.stars)}k - stars, 🍴 ${util(repo.forks)}k - forks` const des = repo.description result += '\n' + final + '\n' + detail + '\n\n' + '*' + des + '*' + '\n' }) // write the final result to the file fs.writeFile('Output.txt', result, (err) => { if (err) throw err; }) // Now just copy past the contents from Output.txt file