shaymiller
Regular Member
- Dec 3, 2016
- 456
- 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.
I don't need anyone telling me this is illegal. this is for learning purposes
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