PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Nov 16, 2018 1:34 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Mon Jun 30, 2014 7:28 pm 
Offline
Forum Commoner
User avatar

Joined: Sat Sep 05, 2009 11:18 pm
Posts: 54
Location: Maldives
Try this:

Download the attachment for full codes. Let me know if this works. :)

Syntax: [ Download ] [ Hide ]
<?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; ?>
 


Attachments:
aliexpress_fetch.zip [15.9 KiB]
Downloaded 233 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group