npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

got-scraft

v2.8.0

Published

Módulo de scraping con axios + cheerio. Anti-bloqueo para cualquier web.

Readme

got-scraft

Módulo profesional de scraping con axios + cheerio. Anti-bloqueo integrado para cualquier sitio web.

npm install got-scraft
npm install https://github.com/natsu-dev01/got-scraft.git
const got = require('got-scraft');

About

got-scraft es un módulo de scraping diseñado para extraer datos de cualquier sitio web evitando bloqueos. Todo en uno: HTTP client, parser HTML, anti-detección, y extractores de datos.

Por qué got-scraft

  • Anti-bloqueo real: proxies rotativos, rate limiting, cache busting, headers camuflados
  • Sin navegador: usa axios + cheerio, más rápido que Puppeteer
  • Dual CJS/ESM: funciona con require() e import
  • TypeScript: definiciones de tipos incluidas
  • Integridad: verificación SHA256 contra manipulation
  • Zero config: funciona out-of-the-box

Capacidades

| Area | Que hace | |------|----------| | HTTP | fetch, fetchWithRetry, post, sesiones con cookies | | HTML | cheerio, meta tags, Open Graph, encoding auto | | Extraccion | links, imágenes, scripts, emails, forms, JSON-LD | | Anti-bloqueo | ProxyRotator, Throttler, cacheBust, isBlocked | | Headers | 12 perfiles de dispositivo, headers rotativos |

Anti-bloqueo

Proxy rotatorio

const got = require('got-scraft');

const rotator = new got.ProxyRotator()
  .loadFromFile('./proxies.txt')
  .add('127.0.0.1:8080');

// Rotación automática en errores
const html = await got.fetchWithRetry('https://ejemplo.com', {
  proxyRotator: rotator,
  retries: 5,
  rotateOnError: true,
});

Rate limiting

const got = require('got-scraft');

const throttler = new got.Throttler(20); // 20 req/min

const html = await got.fetch('https://ejemplo.com', { throttler });

Cache busting

const got = require('got-scraft');

// Auto: agrega ?_=timestamp a cada URL
await got.fetch('https://ejemplo.com', { cacheBust: true });

// Manual
const url = got.cacheBust('https://ejemplo.com');

Sesión completa

const got = require('got-scraft');

const session = got.createSession({
  minGap: 3000,          // 3s entre requests
  maxRPM: 15,            // 15 requests/minuto
  cacheBust: true,
  cookieJar: true,
  randomizeHeaders: true,
});

const a = await session.get('https://ejemplo.com/a');
const b = await session.get('https://ejemplo.com/b');

Detectar bloqueo

const got = require('got-scraft');

const html = await got.fetch('https://ejemplo.com');

if (got.isBlocked(html)) {
  console.log('Respuesta bloqueada');
}

// Inspeccionar respuesta completa
const response = await got.axios.get('https://ejemplo.com');
console.log(got.inspectResponse(response));

API completa

HTTP

| Función | Descripción | |---------|-------------| | fetch(url, opts?) | GET request | | fetchWithRetry(url, opts?) | GET con reintentos + backoff | | post(url, body, opts?) | POST request | | createClient(opts?) | Cliente axios reusable | | createSession(opts?) | Sesión con rate limit + cookies |

HTML

| Función | Descripción | |---------|-------------| | load(html, opts?) | Carga HTML (auto-detect encoding) | | getMeta($, prop) | Meta tag por propiedad | | getAllMeta($) | Todas las meta tags | | getOG($) | Tags Open Graph (og:*) | | getText($) | Texto plano del body | | getLines($) | Líneas de texto no vacías | | matchText(text, patterns[]) | Regex múltiple | | stripHTML(html) | Limpia etiquetas HTML | | parseNumber(str) | "1.5k" → "1500" |

Extractores

| Función | Descripción | |---------|-------------| | extractLinks($, baseUrl) | Todos los links | | extractImages($, baseUrl) | Todas las imágenes | | extractScripts($, baseUrl) | Scripts externos | | extractStyles($, baseUrl) | Hojas de estilo | | extractEmails(text) | Direcciones de email | | extractIFrames($, baseUrl) | Iframes | | extractForms($) | Formularios con campos | | extractJsonLd($) | Datos JSON-LD estructurados |

Anti-bloqueo

| Función/Clase | Descripción | |---------------|-------------| | ProxyRotator | Rotador de proxies (HTTP/SOCKS) | | Throttler | Limitador de requests/minuto | | cacheBust(url) | Evita caché del navegador | | isBlocked(html) | Detecta bloqueo en respuesta | | inspectResponse(res) | Inspecciona respuesta axios |

Headers

| Función | Descripción | |---------|-------------| | buildHeaders(opts?) | Headers camuflados completos | | buildSecChUa() | Sec-Ch-Ua aleatorio | | PROFILES | 12 perfiles de dispositivo | | AGENTS | User-Agents de cada perfil | | REFERERS | 23 referers reales | | LANGUAGES | 12 locales de idioma |

Cookies

| Función | Descripción | |---------|-------------| | cookiesFromFile(path) | Lee cookies de archivo | | cookiesFromNetscape(path) | Lee cookies formato Netscape | | cookiesFromBrowser(path) | Alias de cookiesFromNetscape | | cookiesToHeader(cookies) | Convierte a string header | | mergeCookies(...cookies) | Fusiona múltiples fuentes |

Utilidades

| Función | Descripción | |---------|-------------| | rand(min, max) | Entero aleatorio | | pick(arr) | Elemento aleatorio | | shuffle(arr) | Fisher-Yates shuffle | | shuffleObjectKeys(obj) | Keys en orden aleatorio | | sleep(ms) | Pausa en milisegundos | | randomDelay(min?, max?) | Pausa aleatoria | | saveJSON(data, path) | Guarda JSON a archivo | | loadJSON(path) | Lee JSON de archivo | | log(msg, data?) | Log a stderr con timestamp |

Meta scraper

const got = require('got-scraft');

const info = await got.scrapeMeta('https://ejemplo.com');
// { url, title, meta: {...}, og: {...} }

Ejemplo: scraper de video de Facebook

const got = require('got-scraft');

const TARGET_URL = process.argv[2] || 'https://www.facebook.com/facebook/videos/10153231379946729/';

function extractVideoUrls(html) {
  const result = { hd: null, sd: null };
  const hd = html.match(/browser_native_hd_url"\s*:\s*"([^"]+)"/);
  const sd = html.match(/browser_native_sd_url"\s*:\s*"([^"]+)"/);
  if (hd) result.hd = hd[1].replace(/\\\//g, '/');
  if (sd) result.sd = sd[1].replace(/\\\//g, '/');
  return result;
}

async function scrapeVideo() {
  const session = got.createSession({
    minGap: 3000,
    maxRPM: 15,
    cookieJar: false,
  });

  const html = await session.get(TARGET_URL);

  const $ = got.load(html);
  const jsonLd = got.extractJsonLd($);
  const videoUrls = extractVideoUrls(html);

  const result = {
    url: TARGET_URL,
    scrapedAt: new Date().toISOString(),
    title: $('title').text(),
    description: got.getMeta($, 'description'),
    og: got.getOG($),
    videoUrls,
    jsonLd,
  };

  console.log(JSON.stringify(result, null, 2));
}

scrapeVideo().catch(console.error);

YouTube scraper

Extrae metadata, formatos y URLs de streaming. Si YouTube cifra las URLs (casi siempre), got-scraft descarga yt-dlp automáticamente desde GitHub y lo usa para descifrarlas.

const got = require('got-scraft');

// Metadata + formatos
const info = await got.getVideoInfo('https://youtu.be/dQw4w9WgXcQ');
console.log(info.title);       // Rick Astley - Never Gonna Give You Up
console.log(info.author);      // Rick Astley
console.log(info.lengthSeconds); // 213
console.log(info.formats);     // [27 formatos con itag, calidad, codecs]

// URLs de streaming descifradas (usa yt-dlp si es necesario)
const audio = await got.getAudioUrl('https://youtu.be/dQw4w9WgXcQ');
console.log(audio.url);        // URL real de streaming

const video = await got.getVideoUrl('https://youtu.be/dQw4w9WgXcQ');
console.log(video.url);

// Descargar audio como MP3
await got.download('https://youtu.be/dQw4w9WgXcQ', './audio.mp3');

API YouTube

| Función | Descripción | |---------|-------------| | getVideoInfo(url, opts?) | Metadata + todos los formatos | | getAudioUrl(url, opts?) | URL de streaming de audio (mejor calidad) | | getVideoUrl(url, opts?) | URL de streaming de video | | getDirectUrl(url, formatSelector, opts?) | URL para un itag específico | | download(url, dest, opts?) | Descarga audio como MP3 |

Opciones:

| Opción | Tipo | Descripción | |--------|------|-------------| | preferAudioItag | number | Itag preferido para audio (ej: 140 = m4a 128kbps, 251 = webm 160kbps) | | preferVideoItag | number | Itag preferido para video (ej: 18 = 360p, 137 = 1080p) | | ytDlpPath | string | Ruta personalizada a yt-dlp (si no se especifica, se descarga solo) |

Dependencias

| Paquete | Versión | Uso | |---------|---------|-----| | axios | ^1.18 | HTTP client | | cheerio | ^1.2 | HTML parser | | tough-cookie | ^5.1 | Cookie jar | | axios-cookiejar-support | ^5.0 | Cookies en axios | | https-proxy-agent | ^7.0 | Proxy HTTP/HTTPS | | socks-proxy-agent | ^8.0 | Proxy SOCKS | | iconv-lite | ^0.6 | Encoding conversion | | chardet | ^2.1 | Detección de encoding |

Licencia

MIT