[RESOLVED] Grab and display HTML from between two points
Hi All, long time!!
Basicly, what I am wanting todo is grab a section of HTML of one webpage (lets say...www.fruit.com/grape.html).
And then use that HTML on a local webpage on my server (lets say www.pie.com/steak.php).
I want it to use the HTML, which has been fetched from between two specified points.
So the points lets say are ("<table class="pips">") and will stop grabbing the html at ("</table>")
I hope this makes sense....Im some what tired lol :duck:
Please ask any questions if you do not understand me.
Thanks,
Samm :thumb:
Re: Grab and display HTML from between two points
I do not understand why you need to do this. I assume you have permission from the copyright owner to do this too. ;)
Re: Grab and display HTML from between two points
From a friends website, to my website ;). And yes, permission granted :p
Re: Grab and display HTML from between two points
you can use file_get_contents() to grab a page's contents. then, you can use strpos() and substr() to get the information you'd like.
PHP Code:
<?php
$content = file_get_contents("http://apple.com/pie.htm");
//where we should start and end
$start = "<table class=\"pips\">";
$end = "</table>";
$st_pos = strpos($content, $start) + strlen($start); //starting position
$en_pos = strpos($content, $end); //end position
$content = substr($content, $st_pos, $en_pos - $st_pos);
echo $content;
?>
Re: Grab and display HTML from between two points
Works a treat, thankyou! :)