Python Forum

Full Version: Best way to download the contents of a web directory.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What is the best way to download the contents of my webpage directory:

www.mywebpage.com/uploadFiles/php/uploads

The contents will be lots of separate .mp3 files uploaded by students, probably < 200MB

I can zip them with PHP first if that is better, but maybe it is better to download the small individual files?

Is requests the right tool to use??
(Feb-10-2022, 02:24 AM)Pedroski55 Wrote: [ -> ]I can zip them with PHP first if that is better, but maybe it is better to download the small individual files?
That's up to you to figure what make most sense.
Quote:Is requests the right tool to use??
Yes,quick demo Sample zip files download
import requests
from zipfile import ZipFile

url = 'https://drive.google.com/uc?export=download&id=1o9DtaYEb1N-C_L7kqCAgfE0D5RaEwbZH'
response = requests.get(url)
with open('5mb.zip', 'wb') as f:
    f.write(response.content)

with ZipFile('5mb.zip', 'r') as zip:
    file_name = zip.namelist()
    zip.extractall()

print(file_name[0])
Output:
big_buck_bunny_240p_5mb.3gp
Thanks for your reply!

I completely forgot that I have a bash script which uses rsync to do exactly this job.

I made the bash script last year (with help from linuxquestions.org), but don't use it much lately on the web.

I just changed the paths and it works great! Simple, straightforward, fast!

rsync is a great tool!

I use rsync regularly at home to back up everything from this computer to my older laptop once a week, just in case.