DylanD Posted October 29, 2007 Share Posted October 29, 2007 I want to write a script to go through a list of pages and extract and save an image from the page. An example of the page is this http://www.discogs.com/release/1738 <--I want to download the album cover. I have about 400 of these links so going through and saving each page would take forever. Can I do this in php?? and example or a link to a tutorial would be great.. Thanks Dylan Quote Link to comment https://forums.phpfreaks.com/topic/75219-solved-download-image-for-a-page-script/ Share on other sites More sharing options...
zq29 Posted October 29, 2007 Share Posted October 29, 2007 Something like this should do the trick: <?php $c = file_get_contents("http://www.discogs.com/release/1738"); $i = preg_match("/http:\/\/www\.discogs\.com\/image\/.*\.jpeg/",$c,$match); $im = file_get_contents($match[0]); $h = fopen(basename($match[0]),"w"); fwrite($h,$im); fclose($h); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75219-solved-download-image-for-a-page-script/#findComment-380472 Share on other sites More sharing options...
DylanD Posted October 29, 2007 Author Share Posted October 29, 2007 Works like a charm.. Thank You Very much! Quote Link to comment https://forums.phpfreaks.com/topic/75219-solved-download-image-for-a-page-script/#findComment-380506 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.