Python Forum
Best way to download the contents of a web directory.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best way to download the contents of a web directory.
#1
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??
Reply
#2
(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
Gribouillis likes this post
Reply
#3
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.
ndc85430 likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  download with internet download manager coral_raha 0 2,970 Jul-18-2021, 03:11 PM
Last Post: coral_raha
  A better way to search the contents of a directory? alloydog 5 2,688 Apr-11-2021, 09:12 AM
Last Post: alloydog
  Copy directory (+all contents) via SSH j.crater 7 10,842 Mar-27-2017, 08:39 AM
Last Post: j.crater

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020