tags:

views:

49

answers:

3

Hi everyone,

I try to find the way to get just a part of a web source page ? I'm using php to get the all source code of the page but i don't need to get the entire page source.

Is someone can help me please ?

Joe

+1  A: 

You can use Simple HTML DOM to do that easily.

Example:

// Create DOM from URL or file
$html = file_get_html('http://www.google.com/');

// Find all images
foreach($html->find('img') as $element)
       echo $element->src . '<br>';

// Find all links
foreach($html->find('a') as $element)
       echo $element->href . '<br>'; 

There is more to it, visit the provided link for more information about it.

Note: If you meant server-side source code (PHP, ASP.Net, etc), it is not possible here.

Sarfraz
not really answering the question but I still like the answer :-) +1
Peter Perháč
+1  A: 

HTTP has a couple of request headers that deal with ranges, but even if the server supports them, they aren't a very practical way to get part of a larger HTML document.

You would be better off having the server provide an API which gives you just the information you want (this might involve negotiating with whomever runs the site, if that isn't you).

David Dorward
A: 

okay , Use domain socket connections (fsockopen ) and use fseek to skip parts you don't want.

Arsheep