Last active
November 9, 2017 11:13
-
-
Save devfaysal/eea9b2c541959c48a9828e0215d84943 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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