|
Posted by Koncept on 01/17/07 02:09
In article <1168965554.371518.28080@a75g2000cwd.googlegroups.com>,
Chris Matchett <news.chris@gmail.com> wrote:
> How can I remove everything but the img tag, and it's attributes, from
> the html generated by Google Web Album's RSS item description shown
> below?
>
> I have the code I am using at present below but I was hoping for a more
> reliable alternative.
The regular expression I am using here is VERY basic, but it's another
alternative:
<?php
$html = file_get_contents( "http://www.ebay.com" );
preg_match_all("/<img[^>]+>/", $html, $matches );
foreach( $matches[0] as $match ){
if(preg_match( '/src="([^"]+)"/', $match, $src, PREG_OFFSET_CAPTURE
)){
echo "Got source image : ", $src[1][0], "\n";
}
}
?>
--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit." -Nietzsche
[Back to original message]
|