pay 40$ for script that extract link from html page

Looking to hire a PHP developer for a paid position? Looking for a paid PHP job? Want to post your resume? Let the job hunt begin...

Moderator: General Moderators

Post Reply
User avatar
techkid
Forum Commoner
Posts: 54
Joined: Sat Sep 05, 2009 11:18 pm
Location: Maldives

Re: pay 40$ for script that extract link from html page

Post by techkid »

Try this:

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; ?>
Attachments
aliexpress_fetch.zip
(15.9 KiB) Downloaded 446 times
Post Reply