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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ultra-scraper

v1.0.0

Published

Ultra fast and flexible web scraper with plugin system and smart data extraction

Readme

🚀 Ultra Scraper

Motor universal de web scraping de alto rendimiento

npm version License Node.js

Ultra Scraper es un motor de scraping universal diseñado para manejar cualquier tipo de sitio web: HTTP, HTTPS, estático, dinámico o protegido. Ofrece una API simple, rápida y modular, ideal para bots, automatización, análisis de datos y pipelines empresariales.

InstalaciónUsoDocumentaciónEjemplos


✨ Características principales

🌐 Versatilidad

  • ✅ Soporte para HTTP y HTTPS
  • ✅ Scraping de contenido estático y dinámico
  • ✅ Modo headless opcional (Playwright/Puppeteer)
  • ✅ Compatible con sitios protegidos

⚡ Rendimiento

  • ✅ Parsers de alto rendimiento (Cheerio-like)
  • Auto-reintentos y detección de bloqueos
  • ✅ Rotación de user-agents y proxys
  • ✅ Sistema de plugins extensible

📊 Extracción de datos

  • ✅ HTML, JSON, texto y atributos
  • ✅ Imágenes, videos y archivos media
  • ✅ Selectores CSS y XPath
  • ✅ Extracción estructurada

🛠️ Facilidad de uso

  • ✅ API simple e intuitiva
  • ✅ TypeScript ready
  • ✅ Configuración flexible
  • ✅ Documentación completa

📦 Instalación

npm install ultra-scraper

Requisitos

  • Node.js >= 14.0.0
  • npm o yarn

🧪 Uso básico

Scraping simple

import { createScraper } from "ultra-scraper";

const scraper = createScraper();

// Obtener contenido de una página
const data = await scraper.get("https://example.com");

console.log(data.html);     // HTML completo
console.log(data.status);   // Código de estado HTTP
console.log(data.headers);  // Headers de la respuesta

Scraping con selectores

import { createScraper } from "ultra-scraper";

const scraper = createScraper();

// Extraer elementos específicos
const $ = await scraper.query("https://example.com", "h1");
console.log($.text());  // Texto del h1

// Múltiples elementos
const links = await scraper.query("https://example.com", "a");
links.each((i, elem) => {
  console.log($(elem).attr("href"));
});

🔍 Uso avanzado

Scraping dinámico

Para sitios web que cargan contenido con JavaScript:

import { createScraper } from "ultra-scraper";

const scraper = createScraper({
  dynamic: true,          // Habilita navegador headless
  retries: 3,             // Número de reintentos
  timeout: 12000,         // Timeout en ms
  waitForSelector: ".content"  // Esperar elemento específico
});

const $ = await scraper.query("https://spa-website.com", ".dynamic-content");
console.log($.text());

Configuración de opciones

const scraper = createScraper({
  // Navegación
  dynamic: false,           // Usar navegador headless
  userAgent: "custom-ua",   // User-agent personalizado
  timeout: 10000,           // Timeout en milisegundos
  
  // Reintentos
  retries: 3,               // Número de reintentos
  retryDelay: 1000,         // Delay entre reintentos (ms)
  
  // Headers personalizados
  headers: {
    "Accept-Language": "es-ES",
    "Referer": "https://google.com"
  },
  
  // Proxy
  proxy: "http://proxy:8080"
});

Extracción estructurada

const scraper = createScraper();

const products = await scraper.extract("https://shop.com/products", {
  selector: ".product",
  fields: {
    title: { selector: ".title", attr: "text" },
    price: { selector: ".price", attr: "text" },
    image: { selector: "img", attr: "src" },
    link: { selector: "a", attr: "href" }
  }
});

console.log(products);
// [
//   { title: "Product 1", price: "$10", image: "...", link: "..." },
//   { title: "Product 2", price: "$20", image: "...", link: "..." }
// ]

🧩 Sistema de plugins

Ultra Scraper incluye un sistema de plugins extensible para añadir funcionalidades personalizadas.

Rotación de proxys

import { createScraper, useProxyRotation } from "ultra-scraper";

const scraper = createScraper();

// Configurar rotación automática de proxys
scraper.use(useProxyRotation([
  "http://proxy1.com:8080",
  "http://proxy2.com:8080",
  "http://proxy3.com:8080"
]));

await scraper.get("https://example.com");

User-Agent aleatorio

import { createScraper, useRandomUserAgent } from "ultra-scraper";

const scraper = createScraper();
scraper.use(useRandomUserAgent());

await scraper.get("https://example.com");

Rate limiting

import { createScraper, useRateLimit } from "ultra-scraper";

const scraper = createScraper();

// Limitar a 5 peticiones por segundo
scraper.use(useRateLimit({ requestsPerSecond: 5 }));

await scraper.get("https://example.com");

Crear plugin personalizado

const myPlugin = (scraper) => {
  scraper.on("beforeRequest", (config) => {
    console.log(`Scraping: ${config.url}`);
  });
  
  scraper.on("afterRequest", (response) => {
    console.log(`Status: ${response.status}`);
  });
};

scraper.use(myPlugin);

📚 Ejemplos

Consulta la carpeta examples/ para ver más casos de uso:


🛡️ Manejo de errores

import { createScraper, ScraperError } from "ultra-scraper";

const scraper = createScraper({ retries: 3 });

try {
  const data = await scraper.get("https://example.com");
  console.log(data.html);
} catch (error) {
  if (error instanceof ScraperError) {
    console.error(`Error de scraping: ${error.message}`);
    console.error(`Código: ${error.statusCode}`);
  } else {
    console.error("Error desconocido:", error);
  }
}

📖 API Reference

createScraper(options?)

Crea una nueva instancia del scraper.

Opciones:

  • dynamic (boolean): Habilitar modo headless
  • timeout (number): Timeout en milisegundos
  • retries (number): Número de reintentos
  • userAgent (string): User-agent personalizado
  • headers (object): Headers HTTP personalizados
  • proxy (string): URL del proxy

scraper.get(url, options?)

Obtiene el contenido de una URL.

Retorna: Promise<ScraperResponse>

scraper.query(url, selector, options?)

Extrae elementos usando selectores CSS.

Retorna: Promise<CheerioAPI>

scraper.extract(url, schema, options?)

Extrae datos estructurados según un esquema.

Retorna: Promise<Array<object>>

scraper.use(plugin)

Registra un plugin.


🧪 Testing

# Ejecutar tests
npm test

# Tests en modo watch
npm run test:watch

# Cobertura de código
npm run test:coverage

🤝 Contribuir

¡Las contribuciones son bienvenidas! Si deseas contribuir:

  1. Fork el proyecto
  2. Crea una rama para tu feature (git checkout -b feature/AmazingFeature)
  3. Commit tus cambios (git commit -m 'Add: nueva característica')
  4. Push a la rama (git push origin feature/AmazingFeature)
  5. Abre un Pull Request

📝 Roadmap

  • [ ] Soporte para WebSockets
  • [ ] Integración con bases de datos
  • [ ] Cache inteligente de respuestas
  • [ ] Soporte para CAPTCHA solving
  • [ ] CLI para scraping desde terminal
  • [ ] Dashboard de monitoreo

📄 Licencia

Este proyecto está bajo la licencia Apache-2.0.

Copyright © 2025 Hepein Oficial


🔗 Enlaces


Hecho con ❤️ por Hepein Oficial

Si te gusta este proyecto, ¡dale una ⭐ en GitHub!