PDA

View Full Version : Targeting Exact Line in WebPage and Echoing



embeebutterly
Oct 19th, 2011, 01:24 PM
Hi Guys

i wonder if any one would be able to do this, i know its a hard one!

Im wanting to use the following site but rather than copy pasting links (like they ask you to) i would rather use a script to grab the link and echo it for me.

The reason being i think embedding they channels the offer would be far easier.

So heres the challenge:

The target is the stream url at the bottom of this page: http://www.zapni.tv/play.php?id=100

(looks like this
http://www.zapni.tv/stream/vlc.php?id=100&session=NTEzNjcwMzY2OQ==&stream=play)


the aim is to be able to write it into a player on page load like this:



<embed type="application/x-vlc-plugin" name="VLC" autoplay="yes" loop="no" volume="100" width="640" height="480" target="http://www.zapni.tv/stream/vlc.php?id=100&session=MTk3NjYwODUzOQ==&stream=play">


Cheers Guys in advance, and good luck! :thumbsup:

BTW i only hope Javascript is the correct category if not, sorry :-)

Adee
Oct 19th, 2011, 07:38 PM
uhh i can't be sure exactly what you're trying to do.. but this is how to get that link in php.

(cant be bothered to write a proper regex, but this should do the trick.)

you'll have to change the link in $ch to whatever page you're on..


<?php

$ch = curl_init("http://www.zapni.tv/play.php?id=100");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($ch);

preg_match_all('/(http):\/\/(www\.zapni\.tv\/stream\/vlc\.php)\?(.*)/', $page, $matches);

foreach($matches[0] as $v)
{
echo strip_tags($v) . "<br />";
}



?>

embeebutterly
Oct 20th, 2011, 11:27 AM
uhh i can't be sure exactly what you're trying to do.. but this is how to get that link in php.

(cant be bothered to write a proper regex, but this should do the trick.)

you'll have to change the link in $ch to whatever page you're on..


<?php

$ch = curl_init("http://www.zapni.tv/play.php?id=100");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($ch);

preg_match_all('/(http):\/\/(www\.zapni\.tv\/stream\/vlc\.php)\?(.*)/', $page, $matches);

foreach($matches[0] as $v)
{
echo strip_tags($v) . "<br />";
}



?>





This is great thank you! Works locally using easy php!