Thanks. I know. This was just a test to see if I could download a file. It turns out my problem was I was stripping the off the filename. So the URL didn't have anything to download and the file that was created was empty.
The actual problem I was trying to solve was reading a text file with a list of URL's with filenames and downloading all of them. Here's the code that actually worked: (note I save the complete URL before grabbing...
User Profile
Collapse
-
-
-
dank4201 started a topic urllib.urlretrieve returns a corrupt file when using a variable for filenamein Pythonurllib.urlretrieve returns a corrupt file when using a variable for filename
The code below has two calls to urllib.urlretri eve, the first using a string for the file name. Works great. The second returns the same file name but the file is corrupt.
import urllib
import os
url = 'https://s3.amazonaws.co m/MobiFlexImages/app@axikit.com/splogolawyer.pn g'
# download with string for file name
urllib.urlretri eve(url, "splogolawyer.p ng")
# works great...
No activity results to display
Show More
Leave a comment: