Created
January 1, 2026 05:00
-
-
Save ONLym22/3b4333170b51e725c3e93794713c0188 to your computer and use it in GitHub Desktop.
Uploaded via ONLym Bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const axios = require('axios'); | |
| const cheerio = require('cheerio'); | |
| /** | |
| * @returns {Promise<Object>} Scraped data object | |
| */ | |
| async function scrapeNekoLabsBuildsParser() { | |
| try { | |
| const { data: html } = await axios.get('https://builds.nekolabs.web.id/parser', { | |
| headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' } | |
| }); | |
| const $ = cheerio.load(html); | |
| const sidebarNavigation = $('#sidebar nav .space-y-1 a').map((i, el) => { | |
| const element = $(el); | |
| return { | |
| text: element.find('span').text().trim(), | |
| href: element.attr('href'), | |
| isActive: element.hasClass('bg-[#2E2E2E]') | |
| }; | |
| }).get(); | |
| const formDetails = { | |
| urlInput: { | |
| label: $('#urlInput').closest('.p-5').find('label').text().trim(), | |
| placeholder: $('#urlInput').attr('placeholder') || '' | |
| }, | |
| instructionsInput: { | |
| label: $('#instructionInput').closest('.p-5').find('label').clone().children().remove().end().text().trim(), | |
| placeholder: $('#instructionInput').attr('placeholder') || '' | |
| }, | |
| buttonText: $('#generateBtn span span').last().text().trim(), | |
| poweredBy: $('button[type="submit"] + div span.font-semibold').text().trim() | |
| }; | |
| const resultStats = $('.grid.grid-cols-2.md\:grid-cols-4.gap-4.mt-4 > div').map((i, el) => { | |
| const element = $(el); | |
| return { | |
| metric: element.find('.text-xs.text-gray-500').text().trim(), | |
| icon: element.find('.material-icons').text().trim(), | |
| id: element.find('[id^="stat"]').attr('id') || '' | |
| }; | |
| }).get(); | |
| return { | |
| pageMetadata: { | |
| title: $('title').text().trim(), | |
| description: $('meta[name="description"]').attr('content') || '' | |
| }, | |
| sidebarNavigation, | |
| scraperTool: { | |
| form: formDetails, | |
| resultStatisticsLayout: resultStats | |
| } | |
| }; | |
| } catch (error) { | |
| throw new Error(`Scraping failed: ${error.message}`); | |
| } | |
| } | |
| scrapeNekoLabsBuildsParser() | |
| .then(data => console.log(JSON.stringify(data, null, 2))) | |
| .catch(error => console.error(error.message)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment