Created
November 14, 2014 16:18
-
-
Save montes/07f550e24e8193037f55 to your computer and use it in GitHub Desktop.
Check if images from Google Shopping Feed exist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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