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

Link to comment
Share on other sites

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
)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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>

 

 

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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!!

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.