-2

i want to make a file downloader like wget using php. how can i make this downloader which will download file to my local machine. i have been made this download using file_get_contents() function. This is my code

$raw = file_get_contents($_url);
file_put_contents($_dir, $raw);

But i have seen so many solutions in which they are used curl. but i wan't familiar in curl so i have using file_get_contents() function. is there any other functions which are easy and works more better than file_get_contents().

santosh
  • 343
  • 7
  • 18

2 Answers2

1

Firstly, you should get these urls of songs into list. I do not know what is the structure of your file, but reading files in Python is pretty easy.

To download files I would use urllib library. Here is sample:

from urllib import urlretrieve

songsList = ['http://example.com/song1.mp3', 'http://example.com/song2.mp3']

for song in songsList:
    urlretrieve(song, song.split('/')[-1])

Where songsList is your list with urls to download.

mwarzynski
  • 294
  • 1
  • 7
0

I would start by making a python program that will read the URL's from the list so that they are contained as strings in python. Then you will need to import the urllib.request.urlretrieve into python,(see here) to download the files to the machine. As far as making this run whenever ON and connected to the internet, you would need an if/else statement that can check for internet connection.

This is just a starting point, and it would be helpful to know what you have already begun.

Community
  • 1
  • 1