Re: Screen Scraping with php

From: Date: Fri, 08 Jul 2005 03:56:51 +0000
Subject: Re: Screen Scraping with php
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-218333@lists.php.net to get a copy of this message
On Thu, 2005-07-07 at 23:46, Graham Anderson wrote: > thank Robert :) > > I ran the script and got: > Warning: ereg(): REG_BADRPT on line 6 which is in the ereg function > > > do you know what it could be ? > > will woodshed a bit on ereg > g > On Jul 7, 2005, at 6:51 PM, Robert Cummings wrote: > > > $html = file( > > > > 'http://www.gamespot.com/pc/rpg/guildwars/screens.html?page=264' > > ); > > > > $matches = array(); > > if( ereg( 'END SCREENSHOT NAVIGATION.*?img src="([^")+"', $html, > > $matches ) ) > > { > > $image = $matches[1]; > > } My bad, forgot to use file_get_contents() so as to not have an array, and also forgot that ereg() doesn't support the ? for changing greediness of the matching. The following works as expected (tested :) $html = file_get_contents( 'http://www.gamespot.com/pc/rpg/guildwars/screens.html?page=264' ); $matches = array(); if( preg_match( '/END SCREENSHOT NAVIGATION.*?img src="([^"]+)"/', $html, $matches ) ) { $image = $matches[1]; } echo 'Foo: '.$image."\n"; Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

« previous php.general (#218333) next »