You are here: Re: [PHP] Screen Scraping with php « PHP « IT news, forums, messages
Re: [PHP] Screen Scraping with php

Posted by Robert Cummings on 07/08/05 06:56

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. |
`------------------------------------------------------------'

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация