Trying to extract the Video ID from this page: https://rumble.com/vb5dyh-space-x-we-have-lift-off.html
Specifically, the wildcard value is in the source code on that page as follows:
Rumble("play", {"rel":1,"resize":"auto16:9","opts":["skip_ga_load"],"video":"v8j7rt","div":"videoPlayer"});
The value I'm trying to pull in this example is: v8j7rt
This ID is needed for the embed code.
Example PHP code that I'm experimenting with:
require_once 'simple_html_dom.php';
$url = 'https://rumble.com/vb5dyh-space-x-we-have-lift-off.html';
$html = file_get_contents( $url );
$dom = new DOMDocument();
$pattern='"video":"(.*?)"';
// $pattern='\"video\":\"(.*?)\"';
preg_match($pattern,$dom,$match);
print_r($match);
Can't seem to extract this value. Is this the right approach? If so, what am I doing wrong with the pattern.
It is not necessary to use DOMDocument()
to parse the raw data!
You had an issue with your regex, see below:
<?php
$url = 'https://rumble.com/vb5dyh-space-x-we-have-lift-off.html';
$html = file_get_contents( $url );
preg_match('/"video\":\"(.*?)"/',$html,$match);
print_r($match);
// Array
// (
// [0] => "video":"v8j7rt"
// [1] => v8j7rt
// )