Skip to content

Instantly share code, notes, and snippets.

@montes
Created November 14, 2014 16:18
Show Gist options
  • Save montes/07f550e24e8193037f55 to your computer and use it in GitHub Desktop.
Save montes/07f550e24e8193037f55 to your computer and use it in GitHub Desktop.
Check if images from Google Shopping Feed exist
<?php
$googleShoppingXml = file_get_contents('http://www.url.com/googleshopping.xml');
preg_match_all('~(http://[^\s<]+jpg)~si', $googleShoppingXml, $imagesUrls);
foreach ($imagesUrls[0] as $imageUrl) {
$responseCode = get_headers($imageUrl, 1)[0];
if (stristr($responseCode, '404') !== false)
echo "Image doesn't exists: " . $imageUrl . "\n";
else
echo "OK " . $imageUrl . " - " . $responseCode . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment