定制 ymsoft/telegram-channel-scrapper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ymsoft/telegram-channel-scrapper

最新稳定版本:1.0.1

Composer 安装命令:

composer require ymsoft/telegram-channel-scrapper

包简介

Public telegram channel scrapper.

README 文档

README

Stand With Ukraine

Public telegram channels scrapper

Latest Version on Packagist License

PHP from Packagist PHP Composer Total Downloads

This package is intended for those who need to efficiently scrape a public telegram channel. This is done quite easily:

use Ymsoft\TelegramChannelScrapper\TelegramCS;

$scrapper = new TelegramCS('channel_name');

/** @var \Ymsoft\TelegramChannelScrapper\Entity\Channel $channel */
$channel = $scrapper->getChannel();

/** 
 * By default, you will scrap the latest 20 messages.
 * @var \Illuminate\Support\Collection<\Ymsoft\TelegramChannelScrapper\Entity\Message\Message> $messages 
 */
$messages = $scrapper->getMessages();
$messages->count(); // will return 20

// In order to download 20 more messages you need
$scrapper->loadPrevMessages();

$scrapper->getMessages()->count() // will return 40

// You can download old messages endlessly until you download everything.

Since this package uses illuminate/collections you can use all the methods described here to work with a collection of messages.

/** 
 * @var \Illuminate\Support\Collection<\Ymsoft\TelegramChannelScrapper\Entity\Message\Message> $messages 
 */
$messages = $service->getMessage();
$messages->all();
$messages->count();
$messages->toArray();
$messages->firstWhere('id', 1);
$messages->last();
$messages->first();

// and much more https://laravel.com/docs/10.x/collections#available-methods

Channel

View all entity attributes Channel.

Message

View all entity attributes Message.

Installation

You can install the package via composer:

composer require ymsoft/telegram-channel-scrapper

Advanced usage

Scrap special message by concrete id

If you know the message ID you can get it:

use Ymsoft\TelegramChannelScrapper\TelegramCS;

$service = new TelegramCS('channel_name');

/** @var \Ymsoft\TelegramChannelScrapper\Entity\Message\Message $message */
$message = $service->getMessageById(1);

Http client (CUSTOM HEADERS & PROXY)

If you want to add your own headers or make requests through a proxy, you can pass your http client instance as the second parameter:

use Ymsoft\TelegramChannelScrapper\TelegramCS;

/*
 * You can provide any http client that implements psr/http-client
 * Psr\Http\Client
 */
 
$client = new \GuzzleHttp\Client([
    'headers' => [
        'Accept-Language' => 'en-US,en;q=0.9',
        'Accept' => 'text/html',
    ],
    'proxy' => 'http://localhost:8125',
]);

$service = new TelegramCS('channel_name', $client);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Thank you for considering contributing to the TelegramCS Package!

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 27
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固