Created
May 19, 2026 17:57
-
-
Save SaurusAraAra/28d87746516ad271b8c3f6250150f681 to your computer and use it in GitHub Desktop.
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'); | |
| async function scrapeMcpedlSearch(query = 'shaders', max = 10) { | |
| try { | |
| const { data } = await axios.get( | |
| `https://mcpedl.org/?s=${encodeURIComponent(query)}`, | |
| { | |
| timeout: 30000, | |
| headers: { | |
| 'User-Agent': | |
| 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/91.0.4472.124 Safari/537.36' | |
| } | |
| } | |
| ); | |
| const $ = cheerio.load(data); | |
| const result = []; | |
| $('.g-block.size-20 article').each((i, el) => { | |
| if (i >= max) return false; | |
| const title = | |
| $(el).find('.entry-title a').text().trim() || | |
| 'No title'; | |
| const link = | |
| $(el).find('.entry-title a').attr('href') || | |
| 'No link'; | |
| let image = | |
| $(el).find('.post-thumbnail img').attr('data-srcset') || | |
| $(el).find('.post-thumbnail img').attr('src') || | |
| 'No image'; | |
| if (image.includes(',')) { | |
| image = image.split(',')[0].split(' ')[0]; | |
| } | |
| const rating = | |
| $(el).find('.rating-wrapper span').text().trim() || | |
| 'No rating'; | |
| result.push({ | |
| title, | |
| link, | |
| image, | |
| rating | |
| }); | |
| }); | |
| console.log(JSON.stringify({ | |
| status: true, | |
| total: result.length, | |
| data: result | |
| }, null, 2)); | |
| } catch (e) { | |
| console.error({ | |
| status: false, | |
| message: e.message | |
| }); | |
| } | |
| } | |
| scrapeMcpedlSearch(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment