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

tgstat-parser

v1.0.0

Published

A parser for extracting Telegram channel data from TgStat website

Readme

TgStat Parser

A modular JavaScript parser for extracting Telegram channel data from TgStat website.

Overview

This script extracts structured data from Telegram channel listings on TgStat website (telega.in), including:

  • Channel ID, name, and description
  • Subscriber count and engagement metrics
  • Price information with discounts
  • Subject/category
  • Avatar URL
  • Rating and other metrics

Usage

Browser Bookmarklet

  1. Create a new bookmark in your browser
  2. Name it "TgStat Parser"
  3. In the URL field, paste this code:
javascript:(function(){const script=document.createElement('script');script.src='https://raw.githubusercontent.com/yourusername/tgstat-parser/main/tgstat_parser/browser-url-fetcher.js';document.body.appendChild(script);script.onload=function(){window.tgStatParser.showUI()}})();
  1. Save the bookmark
  2. When viewing any webpage, click the bookmark to run the parser UI
  3. Enter a telega.in URL and click "Parse URL"

Command Line

Install the package:

npm install -g tgstat-parser

Parse a telega.in URL:

tgstat-parser https://telega.in/catalog/investments

Options:

-h, --help             Show help message
-s, --selector <sel>   CSS selector for channel elements (default: '.channels-item')
--no-json              Disable JSON export
--no-csv               Disable CSV export
--json-file <file>     JSON output filename (default: 'tgstat_channels.json')
--csv-file <file>      CSV output filename (default: 'tgstat_channels.csv')

Browser Console

Load the script directly in the browser console:

// Load the standalone script
const script = document.createElement('script');
script.src = 'https://raw.githubusercontent.com/yourusername/tgstat-parser/main/tgstat_parser/browser-url-fetcher.js';
document.body.appendChild(script);

// After script is loaded
script.onload = function() {
  // Show UI
  window.tgStatParser.showUI();
  
  // Or parse URL directly
  window.tgStatParser.parseUrl('https://telega.in/catalog/investments');
};

Node.js

const { extractFromUrl } = require('tgstat-parser/urlFetcher');
const { saveToJson } = require('tgstat-parser/exportUtils');

async function parseData() {
  const url = 'https://telega.in/catalog/investments';
  const channels = await extractFromUrl(url);
  
  // Save to file
  saveToJson(channels, 'channels.json');
  
  // Do something with the data
  console.log(`Parsed ${channels.length} channels`);
}

parseData().catch(console.error);

Features

  • Extract data from telega.in URLs directly
  • Works in both browser and Node.js environments
  • Export data to JSON and CSV formats
  • Handle CORS restrictions in browser with proxy
  • Modular architecture for easy maintenance
  • User-friendly UI in browser environment

File Structure

  • main.js - Main entry point for processing HTML already in the browser
  • urlFetcher.js - Module for fetching and parsing content from telega.in URLs
  • parser.js - Core parsing logic to process multiple channel elements
  • channelExtractor.js - Logic for extracting data from individual channel elements
  • domUtils.js - Utility functions for working with DOM elements
  • exportUtils.js - Functions for exporting data to JSON and CSV formats
  • cli.js - Command line interface for Node.js usage
  • browser-url-fetcher.js - Bundled version for browser usage with UI
  • package.json - Project configuration and dependencies

Output Format

The parser extracts data into this structure:

{
  channelId: "67387",
  channelName: "Павел Шумилов",
  description: "Авторский канал. Акции России, США, Китая...",
  subject: "Инвестиции",
  metrics: {
    subscribers: 18057,
    rating: 122.0,
    apr: 4082, 
    err: 22.6,
    cpv: 3.75
  },
  price: {
    original: 18000.0,
    discounted: 15300.0,
    discountPercent: 15,
    discountType: "sale"
  },
  avatarUrl: "/system/channels/avatars/000/067/387/original/eviNUoDO3Hw.jpg",
  channelAdded: "catalog"
}

Dependencies

  • Node.js >= 14.0.0
  • jsdom (for Node.js DOM parsing)
  • node-fetch (for Node.js HTTP requests)

License

MIT