i have this link
view-source:http://abcast.net/embed.php?file=klaci16&width=750&height=450
i want to fetch only m3u8 attribute from the page on other php page
for example , i have this from the link :
player = videojs("Player", { "sources" : [ { "type": "application/x-mpegURL", "src": "http://live.abcast.net:8081/edge/verc9f615461d48dd8b44c84e0b87c50894/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9OS82LzIwMTcgNTo1OToxOCBQTSZoYXNoX3ZhbHVlPVVPTElSQ3V4NENKM0FoQUhRUWJIYUE9PSZ2YWxpZG1pbnV0ZXM9MTIw" } ], "techOrder" : [ "html5", "flash" ],
i want to get on other php page only this attribute
http://live.abcast.net:8081/edge/verc9f615461d48dd8b44c84e0b87c50894/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9OS82LzIwMTcgNTo1OToxOCBQTSZoYXNoX3ZhbHVlPVVPTElSQ3V4NENKM0FoQUhRUWJIYUE9PSZ2YWxpZG1pbnV0ZXM9MTIw
any help please ? i tryied this code but won't working
<?php
$url="http://abcast.net/embed.php?file=klaci16";
$html = file_get_contents($url);
$doc = new DOMDocument();
@$doc->loadHTML($html);
$tags = $doc->getElementsByTagName('player');
foreach ($tags as $tag) {
echo $lol=$tag->getAttribute('src');
}
?>
Step 1. Search the string with strpos to find 'videojs("Player"' - the needle
Step 2. Remove the everything in the string from the position of the needle using substr
Optional Step : Find the last closing tag of the videojs - something like ");" and remove the remaining data with substr
Step 3. At this point you could use explode with the delimiter as the " (a bit hackish)
Step 4. This will now give you an array of each parameter that was enclosed in the ""
Step 5. You can now access the array get the required data.
<?php
$url="http://abcast.net/embed.php?file=klaci16";
$html = file_get_contents($url);
$find = 'videojs("Player", ';
$pos = strpos($html,$find);
$html = substr($html, $pos+$find,-1); // Position + amount of characters of the needle
$html = explode('"', $html);
print_r($html); // What's the key?
echo $html[11]; // 11 = http://live.abcast.net:8081/edge/verc9f615461d48dd8b44c84e0b87c50894/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9OS82LzIwMTcgNTo1OToxOCBQTSZoYXNoX3ZhbHVlPVVPTElSQ3V4NENKM0FoQUhRUWJIYUE9PSZ2YWxpZG1pbnV0ZXM9MTIw
?>