Skip to content

Instantly share code, notes, and snippets.

@devfaysal
Last active November 9, 2017 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devfaysal/eea9b2c541959c48a9828e0215d84943 to your computer and use it in GitHub Desktop.
Save devfaysal/eea9b2c541959c48a9828e0215d84943 to your computer and use it in GitHub Desktop.
$url = "https://www.aliexpress.com/store/product/GGMM-E5-WiFi-Wireless-Speakers-Bluetooth-Receiver-Portable-MP3-Player-Stereo-Hands-free-Call-HiFi-Speaker/602731_32776280965.html?spm=2114.12010612.0.0.GaXHNJ";
$name = 'e5';
$oldmask = umask(0);
mkdir('/home/faysal/Downloads/aliexpress/'.$name, 0777);
$output = file_get_contents($url);
preg_match_all('/([-a-z0-9_\/:.]+\.(jpg))/i', $output, $url_matches);
$local_path = "/home/faysal/Downloads/"; //replace the path where you want to download the images. Make sure the folder is there and writable.
//Download all images by looping through the urls
for($i=0; $i<count($url_matches[0]); $i ++){//loop through the array $url_matches
$image_url = $url_matches[0][$i];
$img = '/home/faysal/Downloads/aliexpress/'.$name.'/'.$name.$i.'.jpg';
file_put_contents($img, file_get_contents($image_url));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment