Download the attachment for full codes. Let me know if this works.
Code: Select all
<?php
/**
* AliExpress Product Fetch | devNetwork: techKid
* @author Ali Haris (http://twitter.com/iharis)
*/
require 'simple_html_dom.php';
$url = 'http://fr.aliexpress.com/item/1pcs-lot-Portable-Sonar-LCD-Fish-Finder-Alarm-100M-AP-ice/410762949.html';
$html = file_get_html($url);
// Get the product name
foreach ($html->find('#product-name') as $e)
$productName = $e->plaintext;
foreach ($html->find('#sku-price') as $e)
$productPrice = "US $" . $e->plaintext;
$productImages = array();
foreach($html->find('img') as $element) {
if (strpos($element->src, '_50x50.jpg') !== false) {
$img = str_replace('_50x50.jpg', '', $element->src);
array_push($productImages, $img);
}
}
?>
<h1><?php echo $productName; ?></h1>
<p>Price: <?php echo $productPrice; ?></p>
<?php foreach ($productImages as $image): ?>
<img src="<?php echo $image; ?>" alt="" />
<?php endforeach; ?>