Re: Grabbing an external web page

From: Date: Thu, 20 Jun 2002 02:48:36 +0000
Subject: Re: Grabbing an external web page
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-103065@lists.php.net to get a copy of this message
On Wed, Jun 19, 2002 at 01:02:27PM -0400, Miva Guy wrote: > I'm looking to grab pieces of information from a page on another site that > is standard HTML. I know how to read and write the page to my site and event > extract the information if the page is XML. Where I'm stuck is how to get to > the portion of the page to read specific data (i.e. the weather forecast for > that airport). $Data = @file('http://foo.weather.net/'); if ( empty($Data) ) { echo 'Had problem opening file.'; } $Contents = implode('', $Data); Now, put $Contents through a regular expression. preg_match() can pull out the data you want while preg_replace() can delete the data you don't want. preg_match() is probably simpler. There are other functions you can use too, but those are the ones I prefer. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

« previous php.general (#103065) next »