Python Forum
Why the file is not downloaded in full with this script?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why the file is not downloaded in full with this script?
#2
Is there any .mp3 on that terrible "illegal" site that work Dodgy

Back to Python,this is how you download.
import requests

url = 'http://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3'
with open('sample.mp3', 'wb') as f:
    f.write(requests.get(url).content)
Get file name from url.
import requests
import os

url = 'http://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3'
file_name = os.path.basename(url)
with open(file_name, 'wb') as f:
    f.write(requests.get(url).content)
Reply


Messages In This Thread
RE: Why the file is not downloaded in full with this script? - by snippsat - Jan-07-2019, 02:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Downloaded file corrupted emont 5 2,916 Oct-01-2023, 11:32 AM
Last Post: snippsat
  I downloaded a script and I cant run this luoxr18 3 2,091 Apr-16-2023, 09:33 AM
Last Post: Larz60+
  How to make a test data file for the full length of definition? MDRI 6 4,926 Apr-16-2021, 01:47 AM
Last Post: MDRI
  How to create local copies of Python packages so they do not have to be downloaded okhajut 3 3,715 Sep-29-2020, 02:22 PM
Last Post: buran
  Web Form to Python Script to Text File to zip file to web wfsteadman 1 2,921 Aug-09-2020, 02:12 PM
Last Post: snippsat
  Execute full script samuelbachorik 0 2,025 Aug-06-2020, 08:09 PM
Last Post: samuelbachorik
  How to append a tuple full of records to a dbf file in Python? DarkCoder2020 4 5,299 May-29-2020, 02:40 PM
Last Post: DarkCoder2020
  How to create an environment for program downloaded from github StartedNewLife 3 3,235 Jan-25-2020, 06:34 PM
Last Post: ibreeden
  How to get file name without the full path details and without extension aruncom2006 1 8,360 Jan-13-2020, 07:37 AM
Last Post: Larz60+
  How to search full path of specified file SriRajesh 3 3,078 Dec-14-2019, 04:52 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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