I pay 70$ via paypal for a simple php script thant can:

You already did! It is nice to hear thanks.

So, test that new version and let me know if you get new errors.

ok

Yeesssssssss!!! finally it works for me on my local server and that’s good enough.
only problorem is that dont work for other pages of aliexpress :frowning:

Well, Nejah, the problem with pulling information from other sites is that they change as they wish.
What that means is that they may use different routines to display their data depending on various
display options. Therefore, it can be very hard to lock onto the exact image you want to pull out.

In my code I sent to you, I was working on only one page from their site. I also had the smaller image
by mistake. Here is a better version that loads the larger picture and displays it. Since you are planning
to use the images to sell their products, I do not think there is any copyright issues.

Also, note that with this code, you can pull just about anything you need from their catalog pages. But, in
most cases, you might have alter what you are looking for. This is done in the STRPOS areas. You will see
that to locate the larger image, I had to do it in two steps. First, locating the area where the image is
stored and then locating the actual string.

Good luck with your new business… Ernie
[php]

<?PHP // The next two lines are to show all errors, remove after testing error_reporting(E_ALL); ini_set('display_errors', 1); // Get a web file (HTML, XHTML, XML, image, etc.) from a URL. Return an array containing the HTTP server response header fields and content. // This is a CURL function which grabs the page for you function get_web_page( $url ) { $user_agent="Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0 Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 "; $options = array( CURLOPT_CUSTOMREQUEST =>"GET", //set request type post or get CURLOPT_POST =>false, //set to GET CURLOPT_USERAGENT => $user_agent, //set user agent CURLOPT_COOKIEFILE =>"cookie.txt", //set cookie file CURLOPT_COOKIEJAR =>"cookie.txt", //set cookie jar CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } // Read the web page and check for errors: $url = "http://fr.aliexpress.com/item/1pcs-lot-Portable-Sonar-LCD-Fish-Finder-Alarm-100M-AP-ice/410762949.html"; $result = get_web_page( $url ); if ( $result['errno'] != 0 ) echo "... error: bad url, timeout, redirect loop ..."; if ( $result['http_code'] != 200 ) echo "... error: no page, no permissions, no service ..."; $page = $result['content']; // We now have the page, locate the picture and price inside it. First finde the image area on page... $start = strpos($page, '
'); $start2 = strpos($page, '", $start2) + 2; // This item minus one for end of previous item... $picture = substr($page, $start2, $end-$start2); // Place this text into <>'s and it will display on site... echo "
". $picture . "
"; // We have the picture image text, now capture the price $start = strpos($page, '') + 52; // This item plus the length of it... $end = strpos($page, "", $start); // This item minus one for end of previous item... $price = substr($page, $start, $end-$start); // Place this text into <>'s and it will display on site... echo "
". $price . "
"; ?>

[/php]
One last thought, This is set up with a hard-coded $URL string that points at the page. You would want
to create some sort of routine to locate the item and then allow you to call this routine automatically.

Hi again
yes the script work graet with that URL but not for all URL and after a long search I discovered that:
----- “imageURL”: [ ----- is always before jpg file
----- US $----- is always before the total price.

that mean we have to take these 2 text in consideration to make the script work for all pages

see file in attachment


ali express full exemple.txt (54 KB)

Nejah,

This format is a bit different due to it being inside the Javascript code. This is where they show the
float-over zoom-in area on their site. So, the formatting is just a little different.
The following pulls both the picture and price from that area.

Hope that helps. Here is the new version:
[php]

<?PHP // The next two lines are to show all errors, remove after testing error_reporting(E_ALL); ini_set('display_errors', 1); // Get a web file (HTML, XHTML, XML, image, etc.) from a URL. Return an array containing the HTTP server response header fields and content. // This is a CURL function which grabs the page for you function get_web_page( $url ) { $user_agent="Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0 Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 "; $options = array( CURLOPT_CUSTOMREQUEST =>"GET", //set request type post or get CURLOPT_POST =>false, //set to GET CURLOPT_USERAGENT => $user_agent, //set user agent CURLOPT_COOKIEFILE =>"cookie.txt", //set cookie file CURLOPT_COOKIEJAR =>"cookie.txt", //set cookie jar CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } // Read the web page and check for errors: $url = "http://fr.aliexpress.com/item/1pcs-lot-Portable-Sonar-LCD-Fish-Finder-Alarm-100M-AP-ice/410762949.html"; $result = get_web_page( $url ); if ( $result['errno'] != 0 ) echo "... error: bad url, timeout, redirect loop ..."; if ( $result['http_code'] != 200 ) echo "... error: no page, no permissions, no service ..."; $page = $result['content']; // We now have the page, locate the picture and price inside it. First finde the image area on page... $start = strpos($page, '"imageURL": ['); $start2 = strpos($page, 'http:', $start); // This item plus the length of it... $end = strpos($page, ".jpg", $start2) + 4; // This item minus one for end of previous item... $picture = substr($page, $start2, $end-$start2); // Place this text into <>'s and it will display on site... echo "

"; // We have the picture image text, now capture the price $start = strpos($page, 'skuPrice', $start2) + 11; // This item plus the length of it... $end = strpos($page, '"', $start); // This item minus one for end of previous item... $price = substr($page, $start, $end-$start); // Place this text into <>'s and it will display on site... echo "
". $price . "
"; ?>

[/php]
So, this version should work nicely for you. Hope it helps. If so, we can mark this one solved.
Of course, we look forward to your next question. Glad we could help…

Did that new version work for you? Just curious…

hi friend
Finally I understood you php magic !!
I made a page that pick up price and weight and another one to pick images and it work fine until now
[php]

$begin = strpos($page, ‘<dd class=“pnl-packaging-size” rel’) +32;

$begin2 = strpos($page, ‘=’ ,$begin) +2; // This item plus the length of it…
$end = strpos($page, “>”, $begin2) -1; // This item minus one for end of previous item…
$packing = substr($page, $begin2, $end-$begin2); // Place this text into <>‘s and it will display on site…
$packing=str_replace(’|’,’ cm* ',$packing);
echo “$packing cm”;

$begin = strpos($page, ‘pnl-packaging-weight" rel’) ;
$begin2 = strpos($page, ‘="’ ,$begin) +2; // This item plus the length of it…
$end = strpos($page, “>”, $begin2) -1; // This item minus one for end of previous item…
$weight = substr($page, $begin2, $end-$begin2); // Place this text into <>'s and it will display on site…
echo $weight;

[/php]

Thanks a lot my friend, you a genius :stuck_out_tongue:

Congratulations on getting it to work. Glad I could help. Now go and make some money with it!

I will mark this one closed. When you run into another issue, please start a new post. Glad to meet you!

Thanks a lot, your forum is the best ever

Sponsor our Newsletter | Privacy Policy | Terms of Service