Jump to content

Displaying certain Lines in websites source code?


TFD3

Recommended Posts

I would like to find a script that I can display only certain line of text from a websites source code.

Im looking for some script where I can add the URL I want, then add the line number from the source code and have the script only display that line that I chose.

 

Example:

 

Using this URL:

and viewing the Source Code and search for LINE 155

LINE 155: var fullscreenUrl = '/watch_fullscreen?video_id=.........

 

BUT...I would like to have a way to cut out  (    var fullscreenUrl = '/    )

Is this possible?

 

thanks

kenny

the file command will read the page into an array with a numeric key.  You can use that to echo out a specific line...just remember that the key will start at 0.

 

http://www.php.net/file

 

$url = "www.google.com";
$line = 10;

$web_page = file($url);

echo "Line " . $line . " of page " . $url . " is:\n" . $web_page[$line - 1];

i try

$url = "http://youtube.com/watch?v=AhO5Pkm3k_8";
$web_page = file_get_contents($url);
preg_match("/var fullscreenUrl = '\/([^']+)/",$web_page,$a);
print_r($a);

it putput is

Array
(
    [0] => var fullscreenUrl = '/watch_fullscreen?video_id=AhO5Pkm3k_8&l=9&t=OEgsToPDskLLZcUW8ZuGr37z_i-zsMBf&sk=Me5nFbc9_C4gD2CLqrGoGAC&fs=1&title=Boxer beats up  frisbee
    [1] => watch_fullscreen?video_id=AhO5Pkm3k_8&l=9&t=OEgsToPDskLLZcUW8ZuGr37z_i-zsMBf&sk=Me5nFbc9_C4gD2CLqrGoGAC&fs=1&title=Boxer beats up  frisbee
)

i try

$url = "http://youtube.com/watch?v=AhO5Pkm3k_8";
$web_page = file_get_contents($url);
preg_match("/var fullscreenUrl = '\/([^']+)/",$web_page,$a);
print_r($a);

it putput is

Array
(
    [0] => var fullscreenUrl = '/watch_fullscreen?video_id=AhO5Pkm3k_8&l=9&t=OEgsToPDskLLZcUW8ZuGr37z_i-zsMBf&sk=Me5nFbc9_C4gD2CLqrGoGAC&fs=1&title=Boxer beats up  frisbee
    [1] => watch_fullscreen?video_id=AhO5Pkm3k_8&l=9&t=OEgsToPDskLLZcUW8ZuGr37z_i-zsMBf&sk=Me5nFbc9_C4gD2CLqrGoGAC&fs=1&title=Boxer beats up  frisbee
)

 

 

Strange....

I tried that same code and I got a blank page:

http://www.alabamaweather.org/psp/youtube/test.php

in source of your link i see

<php
$url = "http://youtube.com/watch?v=AhO5Pkm3k_8";
$web_page = file_get_contents($url);
preg_match("/var fullscreenUrl = '\/([^']+)/",$web_page,$a);
print_r($a);
?>



<BR><BR><BR>

<pre>w


  OR  

<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home2/alabamaw/public_html/psp/youtube/test.php</b> on line <b>27</b><br />


  OR  

w


  OR  

<br />
<b>Warning</b>:  implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed in <b>/home2/alabamaw/public_html/psp/youtube/test.php</b> on line <b>41</b><br />

source code of script

it is because PHP does not pharse it

what the rest of script does?

I forgot to have this added. the first two words of the outputted URL is watch_fullscreen.

I need that replaced with get_video can that be added to the script below?

I already had this script partly working before I got on here and just played with it to get it to work but I forgot about the replace watch_fullscreen to get_video.

 

 

<a href="http://www.youtube.com/<?php

$html = implode('', file("http://youtube.com/watch?v=bcr6IBnuVHQ"));


preg_match_all("/var fullscreenUrl = '\/([^']+)/", $html, $headers);

$count = count($headers[1]);

for ($x = 0; $x <= $count-1; $x++) {
  echo $headers[1][$x]."\n";
}
?>">Get Video</a>

 

 

try

<a href="http://www.youtube.com/get_video<?php
$html = implode('', file("http://youtube.com/watch?v=bcr6IBnuVHQ"));
preg_match_all("/var fullscreenUrl = '\/watch_fullscreen([^']+)/", $html, $headers);
echo $headers[1]."\n";
}
?>">Get Video</a>

try

<a href="http://www.youtube.com/get_video<?php
$html = implode('', file("http://youtube.com/watch?v=bcr6IBnuVHQ"));
preg_match_all("/var fullscreenUrl = '\/watch_fullscreen([^']+)/", $html, $headers);
echo $headers[1]."\n";
}
?>">Get Video</a>

 

That worked, thanks for your help!!

try

<a href="http://www.youtube.com/get_video<?php
$html = implode('', file("http://youtube.com/watch?v=bcr6IBnuVHQ"));
preg_match_all("/var fullscreenUrl = '\/watch_fullscreen([^']+)/", $html, $headers);
echo $headers[1]."\n";
}
?>">Get Video</a>

 

Using the preg_match_all line in the script above, can it be changed to display only

sqMv7mjebvk from the line:

var pageVideoId = 'sqMv7mjebvk'; from the source code of the youtube video link??

 

Thanks guys for your help!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.