PHP code example of cable8mm / mma-scrapers

1. Go to this page and download the library: Download cable8mm/mma-scrapers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cable8mm / mma-scrapers example snippets


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

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

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

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');

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

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

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

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);

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);

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);

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

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
);

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')
);

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

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

$this->assertNotEmpty($fights);