-1

Hey i want to get the files downloaded from https://files.transtutors.com/cdn/usersolution/1404331_1_637266356378408650_o.docx saved to my replit directory with the file name doc.zip can u help me plz i am using discord.py

i am expecting to get the files from the link: https://files.transtutors.com/cdn/usersolution/1404331_1_637266356378408650_o.docx get downloaded with the file name : doc.zip in replit directory

idk
  • 1
  • 1
  • Please let us know what you have tried so far. Additionally, your question contains the same text twice. – ahuemmer Mar 28 '22 at 10:49

1 Answers1

0

This is not related to discord.py but anyways

You can use urllib.request.urlopen()


from urllib.request import urlopen # import the method

with urlopen("http://example.com/") as download: # open the url
    file_content = download.read().decode() # save and decode the download content

with open("doc.zip", "a") as file: # append to the existing zip, else create a new one
    file.write(file_content) # write the content into the file

Check this question as well: How to download a file over HTTP?

Toby Cm
  • 136
  • 6