PHP Developers Network
http://forums.devnetwork.net/

pay 40$ for script that extract link from html page
http://forums.devnetwork.net/viewtopic.php?f=17&t=139776
Page 1 of 1

Author:  techkid [ Mon Jun 30, 2014 7:28 pm ]
Post subject:  Re: pay 40$ for script that extract link from html page

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 397 times

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/