Hallo zusammen,
ich versuche gerade das Image von Amazon auszulesen, allerdings wird mir nichts angezeigt.
Der Preis ist auslesbar.
Hat jemand eine Idee?
Hier der Code:
LGPHP-Code:function get_data($url)
{
/* do some curl magic */
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function get_match($regex, $content, $pos = 1)
{
/* do your job */
preg_match($regex, $content, $matches);
/* return our result */
return $matches[intval($pos)];
}
function amazonCrawler($url)
{
/* grab some data */
$amazon_content = get_data($url);
$amazon['price'] = @get_match('!<span id="priceblock_ourprice" class="a-size-medium a-color-price">(.+)</span>!iUm', $amazon_content);
$amazon['image'] = @get_match('/<div id="imgTagWrapperId" class="imgTagWrapper" style="(.*?)">.*?<img alt="(.*?)" src="(.*?)" data-old-hires="(.*?)" class="(.*?)" id="landingImage" data-a-dynamic-image="(.*?)" style="(.*?)">.*?<\/div>/s', $amazon_content, 3);
$array = array(
$amazon['price'],
$amazon['image']
);
return ($array);
}
list($amazon['price'], $amazon['image']) = amazonCrawler('https://www.amazon.de/Sony-Kompaktkamera-Klarbild-Zoom-Weitwinkelobjektiv-Bildstabilisator/dp/B00W46KQ5W/ref=s9_ri_gw_g23_i1_r?pf_rd_m=A3JWKAKR8XB7XF&pf_rd_s=&pf_rd_r=XDZ21RBKDZZXXCAT2CMK&pf_rd_t=36701&pf_rd_p=c3435e44-81b4-4c2f-9f8b-9b818660cb26&pf_rd_i=desktop');
echo "22222<br /><br />";
echo "Preis: ".$amazon['price']."<br />";
echo "Image: ".$amazon['image'];

