Direct download mp3 files

shaymiller

Regular Member
Joined
Dec 3, 2016
Messages
456
Reaction score
45
I scrape urls for mp3 files. Then play them as remote URL. Those sites keep getting closed/changed. Then I have to go back change my scraper. Is there a php script to download those to directly to my directory? I found the code below, but it doesn't play that mp3. Mainly because its not an audio mp3 file.

Code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'someURL.mp3');

//Create a new file where you want to save
$fp = fopen('filename.mp3', 'w');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec ($ch);
curl_close ($ch);
fclose($fp);


I don't need anyone telling me this is illegal. this is for learning purposes
 
Back
Top