承接 cable8mm/mma-scrapers 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

cable8mm/mma-scrapers

Composer 安装命令:

composer require cable8mm/mma-scrapers

包简介

A lightweight, extensible PHP library for scraping MMA data from multiple sources.

README 文档

README

A lightweight PHP library for scraping and parsing MMA data into simple DTOs.

build & tests coding style deploy-to-github-pages update changelog Packagist Dependency Version Packagist Version Packagist Downloads Packagist Stars GitHub License

Features

  • Source-specific scrapers and parsers for MMA websites.
  • Normalized DTOs for events, fights, and fighters.
  • Fixture-friendly parser design using Symfony DomCrawler.
  • Mockable HTTP layer through HttpClientInterface.
  • Helper services for fighter matching, Sherdog ID resolution, and fight deduplication.
  • No database dependency.

Requirements

  • PHP ^8.4
  • Composer

Installation

composer require cable8mm/mma-scrapers

For local development:

composer install

Supported Sources

Source Events Event detail Fights Fighters Notes
BlackCombat Yes Yes Yes Yes Official source support
Sherdog No No No Yes Fighter search and fighter detail support
Tapology No No No No Planned source

Core Concepts

The library is organized around a small pipeline:

HTTP client -> Scraper -> Parser -> DTO

Scrapers fetch HTML and delegate extraction to parsers. Parsers are deterministic and return DTOs. Aggregators and services are available when a consuming app needs to compare, merge, or deduplicate parsed results.

Project Structure

src/
  Aggregators/      Merge related event, fight, and fighter DTOs
  Contracts/        Scraper and HTTP interfaces
  DTO/              EventDTO, FightDTO, FighterDTO
  Enums/            Source, fight status, fight method, weight class
  Http/             Guzzle HTTP client implementation
  Matchers/         Fighter matching helpers
  Normalizers/      Text-to-enum normalization helpers
  Services/         Sherdog ID resolution and fight deduplication
  Sources/
    BlackCombat/
      Parsers/
      Scrapers/
    Sherdog/
      Parsers/
      Scrapers/

Usage

Parse BlackCombat Events From HTML

use Cable8mm\MmaScrapers\Sources\BlackCombat\Parsers\ParseEvents;

$html = file_get_contents('blackcombat_events.html');

$parser = new ParseEvents();
$events = $parser($html);

Scrape BlackCombat Events

use Cable8mm\MmaScrapers\Http\DefaultHttpClient;
use Cable8mm\MmaScrapers\Sources\BlackCombat\Parsers\ParseEvents;
use Cable8mm\MmaScrapers\Sources\BlackCombat\Scrapers\EventsScraper;

$scraper = new EventsScraper(
    new DefaultHttpClient(),
    new ParseEvents()
);

$events = $scraper->scrape('https://www.blackcombat-official.com/event.php?page=10');

Parse BlackCombat Fights

use Cable8mm\MmaScrapers\Sources\BlackCombat\Parsers\ParseFights;

$html = file_get_contents('event_detail.html');

$parser = new ParseFights();
$fights = $parser($html);

Scrape a Sherdog Fighter

use Cable8mm\MmaScrapers\Http\DefaultHttpClient;
use Cable8mm\MmaScrapers\Sources\Sherdog\Parsers\ParseFighter;
use Cable8mm\MmaScrapers\Sources\Sherdog\Scrapers\FighterScraper;

$scraper = new FighterScraper(
    new DefaultHttpClient(),
    new ParseFighter()
);

$fighter = $scraper->scrapeById(12345);

Resolve a Sherdog Fighter ID

use Cable8mm\MmaScrapers\Http\DefaultHttpClient;
use Cable8mm\MmaScrapers\Services\SherdogIdResolver;
use Cable8mm\MmaScrapers\Sources\Sherdog\Parsers\ParseSearchResults;
use Cable8mm\MmaScrapers\Sources\Sherdog\Scrapers\SearchFighterScraper;

$search = new SearchFighterScraper(new DefaultHttpClient());
$parser = new ParseSearchResults();
$resolver = new SherdogIdResolver();

$html = $search->search('Chan Sung Jung');
$candidates = $parser($html);

$sherdogId = $resolver->resolve('Chan Sung Jung', $candidates);

Deduplicate Fights

use Cable8mm\MmaScrapers\Aggregators\FightAggregator;
use Cable8mm\MmaScrapers\Aggregators\FighterAggregator;
use Cable8mm\MmaScrapers\Services\FightDeduplicator;

$deduplicator = new FightDeduplicator(
    new FightAggregator(new FighterAggregator())
);

$deduplicatedFights = $deduplicator->deduplicate($fights);

DTOs

EventDTO

new EventDTO(
    name: 'Black Combat 16',
    location: 'Incheon, South Korea',
    date: new DateTimeImmutable('2026-01-31'),
    url: '/eventDetail.php?eventSeq=285',
    externalId: '285'
);

FighterDTO

new FighterDTO(
    name: 'Chan Sung Jung',
    nickname: 'The Korean Zombie',
    instagram: 'koreanzombiemma',
    teamname: 'Korean Zombie MMA',
    height: '170cm',
    win: 17,
    lose: 8,
    draw: 0,
    sherdogId: 36155
);

FightDTO

use Cable8mm\MmaScrapers\Enums\FightMethod;
use Cable8mm\MmaScrapers\Enums\FightStatus;
use Cable8mm\MmaScrapers\Enums\Source;
use Cable8mm\MmaScrapers\Enums\WeightClass;

new FightDTO(
    redFighter: $redFighter,
    blueFighter: $blueFighter,
    source: Source::OFFICIAL,
    status: FightStatus::FINISHED,
    weightClass: WeightClass::FEATHERWEIGHT,
    method: FightMethod::KO,
    round: 1,
    time: '3:14',
    winner: $redFighter,
    fightDate: new DateTimeImmutable('2026-01-31')
);

Design Rules

  • Keep source implementations isolated under src/Sources/{SourceName}.
  • Put HTTP access in scrapers, not parsers.
  • Keep parsers deterministic: raw HTML in, DTOs out.
  • Test parsers with static HTML fixtures.
  • Keep storage, API delivery, and application workflows outside this package.

Development

Run tests:

composer test

Run Pint:

composer lint

Generate API documentation:

composer apidoc

Testing

Parser and scraper tests use HTML fixtures from tests/Fixtures.

$html = file_get_contents(__DIR__.'/../../Fixtures/BlackCombat/event_detail.html');

$parser = new ParseFights();
$fights = $parser($html);

$this->assertNotEmpty($fights);

Avoid real HTTP calls in tests. Inject a mocked HttpClientInterface when testing scrapers.

Contributing

  1. Keep the existing source/parser/scraper boundaries.
  2. Add or update fixtures for parser changes.
  3. Add unit tests for new behavior.
  4. Run composer test and composer lint before opening a pull request.

License

MMA Scrapers is open-sourced software licensed under the MIT license.

cable8mm/mma-scrapers 适用场景与选型建议

cable8mm/mma-scrapers 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 58 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「scraper」 「crawler」 「web-scraping」 「dom-crawler」 「data-extraction」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 cable8mm/mma-scrapers 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cable8mm/mma-scrapers 我们能提供哪些服务?
定制开发 / 二次开发

基于 cable8mm/mma-scrapers 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-23