GithubHelp home page GithubHelp logo

nuzulul / telegram-scraper Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 6.0 32 KB

A simple Telegram channel scraper

Home Page: https://codesandbox.io/p/devbox/telegram-channel-scraper-q9g93l

License: MIT License

JavaScript 100.00%
bot html-parser scraper telegram telegram-bot telegram-channel-scraper telegram-scraper web-scraper web-scraping telegram-channel-to-json

telegram-scraper's Introduction

telegram-scraper

A simple Telegram channel scraper

Features

  • ✅ 0 Dependencies
  • ✅ No Authentication
  • ✅ JSON Output

Demo

https://codesandbox.io/p/devbox/telegram-channel-scraper-q9g93l

Installation

npm install telegram-scraper

Example Usage

import {telegram_scraper} from 'telegram-scraper'

void async function main() {

	let telegram_channel_username = 'telegram'

	let result = await telegram_scraper(telegram_channel_username)

	console.log(result)
	
}()
const {telegram_scraper} = require('telegram-scraper')

void async function main() {

	let telegram_channel_username = 'telegram'

	let result = await telegram_scraper(telegram_channel_username)

	console.log(result)
	
}()

Example App

const {telegram_scraper} = require('telegram-scraper')

const http = require('http')

const serverport =  process.env.PORT || 8080

let telegram_channel = 'telegram'

const server = http.createServer(async(req,res)=>{

	let result = await telegram_scraper(telegram_channel)

	res.statusCode = 200
	
	res.setHeader('Content-Type','application/json')
	
	res.setHeader('Access-Control-Allow-Origin','*')
	
	res.end(result)
	
})

server.listen(serverport,()=>{

	console.log(`Server running at ${serverport}`) 
	
})

Example Output

[
    {
        "data_post": "telegram/258",
        "data_view": "eyJjIjotMTAwNTY0MDg5MiwicCI6MjU4LCJ0IjoxNzA2OTQ3MjY0LCJoIjoiMTcwN2E5NzJjMTgzM2I2ZTM0In0",
        "user_url": "https://t.me/telegram",
        "user_photo": "https://cdn1.cdn-telegram.org/file/GFUVa7B7wr28OE5SeJ1yJnZaCmd8P4sP4-d_oCTURVJ6hUSRP9Y_nb2QxQWcpNnJDfV-4kByP7EKCmhoLaTFif02B3DV_7V5dixuLFdSICCSFs1s7gAZJNkLzsUAqYmkTGfmPZnHL58r9ljEXZGUIH6pHJz-Rn7BAfQHxA-Y87exrv4LsNLL68aFGRs9vsb71EcnxxymG50u-wsysTJ4u_aql1PzOWh4TX1TyCjHTlPJl3VmwMJinm77kUl-YtptIbnTCclnXuSvLlA0Z4B1lFVSzg1FX-JyX_xfo6FmvXtkhmEjnWzAYmlZ10qAorIr07hYdaFrwSS_nO0LLQ9bgg.jpg",
        "user_name": "Telegram News",
        "message_url": "https://t.me/telegram/258",
        "message_text": "For 8 more features from this update, like code highlighting in messages, custom reactions for channels, unique colors and logos for your profile, voice-to-text for everyone and more – check out the latest blog: https://telegram.org/blog/similar-channels  November Features 1 • 2 • 3 • More",
        "message_photo": [],
        "message_video": [],
        "views": "4.5M",
        "datetime": "2023-12-04T13:27:19+00:00"
    },
    {
        "data_post": "telegram/259",
        "data_view": "eyJjIjotMTAwNTY0MDg5MiwicCI6MjU5LCJ0IjoxNzA2OTQ3MjY0LCJoIjoiZDI3Y2QzY2NiNzViNjMwYWI2In0",
        "user_url": "https://t.me/telegram",
        "user_photo": "https://cdn1.cdn-telegram.org/file/GFUVa7B7wr28OE5SeJ1yJnZaCmd8P4sP4-d_oCTURVJ6hUSRP9Y_nb2QxQWcpNnJDfV-4kByP7EKCmhoLaTFif02B3DV_7V5dixuLFdSICCSFs1s7gAZJNkLzsUAqYmkTGfmPZnHL58r9ljEXZGUIH6pHJz-Rn7BAfQHxA-Y87exrv4LsNLL68aFGRs9vsb71EcnxxymG50u-wsysTJ4u_aql1PzOWh4TX1TyCjHTlPJl3VmwMJinm77kUl-YtptIbnTCclnXuSvLlA0Z4B1lFVSzg1FX-JyX_xfo6FmvXtkhmEjnWzAYmlZ10qAorIr07hYdaFrwSS_nO0LLQ9bgg.jpg",
        "user_name": "Telegram News",
        "message_url": "https://t.me/telegram/259",
        "message_text": "Stylize Your Channel. As channels level up from subscriber boosts and giveaways, they can customize their profile, set an emoji status, add unique wallpapers and more. 🏡❄️🚗  December Features ❄️ 1 • 2 • 3 • 4 • More",
        "message_photo": [],
        "message_video": [
            "https://cdn1.cdn-telegram.org/file/78f54bd0b3.mp4?token=YKBucZbZzGZELrwA1gLSWX0GrJKfGsZaheQchVc8K2LurR2_3KBJFp1obTLdlYdpig-zhVamIjnR5lTRm0TG4OotEAvvwF1RycDz8mU_8hjISNQmdhKhG_lKbZTYRfySR0oko8sU8arZ9azdzY2qmz9kqsI8kbr6k5ZRxIoZmmjnQozewGGGRQeVQOOrMCmd09YqNZtT28n3v_KO9rVfpliYfGBr-cRzr2IQgc3pRybOYtFkwge4Nnx0b7urT-GkekjGx4C6z-vpMNbIJROwg3R7O2Ym-Ep2enJmlefOs0iL8z886kVD6XxSoFXBBe4LyUcGxLbsOeltvLthsGcKmA"
        ],
        "views": "2.3M",
        "datetime": "2023-12-24T17:44:05+00:00"
    }
]

License

MIT

Maintainers

Nuzulul Zulkarnain

telegram-scraper's People

Contributors

nuzulul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

telegram-scraper's Issues

links are not parsed

if there is a hyperlink in the telegram message, then the information about the hyperlink is lost after scraping

Scraper returns only 20 messages maximum

I've looked into this and it seems that the HTML string returned by https.get() contains only 20 message divs.
I have no idea how this could be fixed, so if you want to fix it, I cant help, sorry 😄
But I would want to get more than 20 messages at once.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.