RE: [PHP] html parsing question

From: Date: Fri, 03 Aug 2001 06:56:15 +0000
Subject: RE: [PHP] html parsing question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-61089@lists.php.net to get a copy of this message
below is a snippet from a larger code used to capture a daily output graphic file from a site... I put your requirements into it and removed a lot of superfluous stuff, but it is not set to capture text spanning more than one line, but you should be able to modify it accordingly if you can follow the logic. >on 8/2/01 5:30 PM, Chuck Barnett at xobyte@bellsouth.net wrote: > >> Hi I have a question about parsing a page on another server to grab some >> headlines. >> >> I want to search down the page until I find a string "-headlines-" then I >> want to grab everything between the next pair of <table></table> tags. >> >> Anyone have a quick solution? > >i would check out http://php.net/strpos > <?PHP /* HTML Content Grabber no copyright */ $file_url = "http://www.somewhere.com/"; $grabbed_file = file($file_url); if ($grabbed_file[0]) { for ($i = 0; $i <= count($grabbed_file) - 1; $i++) { if($returnstr = strstr ($grabbed_file[$i], '-headlines-')) { $trim = substr ($returnstr, strpos($returnstr, '<table>')+7,strpos($returnstr, '</table>')-(strpos($returnstr, '<table>')+7)); }else{ # not in this line, keep searching } } } else { # Something went wrong } ?>

« previous php.general (#61089) next »