PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Miraz Mac   PHP YouTube Video Scraper   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP YouTube Video Scraper
Get details about videos scraping YouTube pages
Author: By
Last change:
Date: 5 years ago
Size: 1,593 bytes
 

Contents

Class file image Download

FackTube

YouTube Public Data Scrapper that parses HTML for the data

FackTube is a scrapper for retrieving YouTube public data. Currently it can only scrape videos. Channels, playlists and single video will be added in future. Feel free to fork and add.

It's not a reliable method for fetching data unless you use tons of paid proxies. And I wouldn't recommend using it on Production either. But hey, YouTube's been a real jerk lately with their Data API v3. It's the least we can do, so lets fack on YouTube.

Install via Composer

composer require mirazmac/facktube

Limitations

  • You can't limit or change the amount of results per page
  • It depends on YouTube's internal html output, and since YouTube heavily relies on JavaScript it can only show the results YouTube provides with no filter whatsoever
  • Its illegal and YouTube may block your IP if you send too many requests

Usage

Check usage folder for complete usage examples.

Searching Videos

use MirazMac\FackTube\FackTube;

$fack = new FackTube($options);

try {
    $results = $fack->videos('Honest Trailer');
} catch (\Exception $e) {
    echo $e->getMessage();
    exit();
}

print_r($results);

But hey, if html parsing is so messy, Why not AJAX endpoints?

Well, yeah I did that previously with https://github.com/MirazMac/YouScrape and now YouTube completely revamped their AJAX endpoints with session based Tokens and other stuff. So, thats a no no. But if you find a way to bypass those create a new repo and let me know, I'll be happy to contribute.