I am trying to download a particular file to a specific folder on my hardisk. I am using IronPython 2.7 and urllib
module.
I tried downloading the file with the following code:
import urllib
response = urllib.urlretrieve(someURL, 'C:/someFolder')
html = response.read()
response.close()
But when upper code is ran, I get the following error message:
Runtime error (IOException): Access to the path 'D:\someFolder' is denied.
Traceback:
line 91, in urlretrieve, "C:\Program Files\IronPython\Lib\urllib.py"
line 9, in script
line 241, in retrieve, "C:\Program Files\IronPython\Lib\urllib.py"
I tried entering the Attributes of my "someFolder", and found out the "Read-only" is checked. I unchecked it, clicked "Apply" and "Ok". But when I come back again, "Read-only" is checked again. No matter how many times I uncheck it and confirm, it the "sameFolder" still remains "Read-only". Is this the reason why I am getting the upper error message?
Hot to fix it? I tried moving the "someFolder" to other partitions, but still for some reason I can not uncheck the "Read-only" attribute (I can, but it just keeps coming back).
Thank you for the reply.
I forgot to say that I use Windows XP 32 bit.
EDIT: I checked if "someFolder" is writable and it is. The following code:
print os.access("C:/someFolder", os.W_OK)
returns: True
.
You may want to use this instead:
import os
import urllib
fullfilename = os.path.join('C:/somedir', 'test.html')
urllib.urlretrieve("http://www.google.com", fullfilename)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With