Upload file to specific folder using python

I am trying to download a specific file to a specific folder on my hard drive. I am using IronPython 2.7 and urllib.

I tried downloading the file with the following code:

import urllib

response = urllib.urlretrieve(someURL, 'C:/someFolder')
html = response.read()
response.close()  

But when the top code is executed, the following error message appears:

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 to enter the attributes of my "someFolder" and found that "Read-only" is checked. I disabled it, clicked "Apply" and "Good." But when I get back again, Read-Only is checked again. No matter how many times I take it off and confirm it, this sameFolder is still read-only. Is this the reason I am getting a top-level error message?

, ? "someFolder" , - " " ( , ).

.

, 32- Windows XP.

EDIT: , "someFolder" , . :

print os.access("C:/someFolder", os.W_OK)

: True.

+4
1

:

import os
import urllib

fullfilename = os.path.join('C:/somedir', 'test.html')
urllib.urlretrieve("http://www.google.com", fullfilename)
+3

Source: https://habr.com/ru/post/1609388/


All Articles