assuming my link is : web_link = 'https://link'
and my destination file that i want the content to be downloaded in is path.
How can i download the content of web_link in path knowing that i'm using python2.7.
            Asked
            
        
        
            Active
            
        
            Viewed 5,594 times
        
    1
            
            
         
    
    
        Alex
        
- 49
- 3
- 7
- 
                    You don't do `web_link = 'https://link'` if you want to download the file in the `link` folder. you simply do `web_link = 'link/'` – David Hope Oct 26 '17 at 12:26
- 
                    I checked that answer and few others before i post here, it just didn't work as there was no path to where he wanted to download his content(in my case .flac files) – Alex Oct 26 '17 at 12:28
- 
                    David, not sure about that, what if i wanted to download my content from a gs:// – Alex Oct 26 '17 at 12:29
1 Answers
2
            You can download using urllib:-
Python 2
import urllib 
urllib.urlretrieve("web_link", "path")   
you can use requests if weblink needs authentication :
import requests
r = requests.get(web_link, auth=('usrname', 'password'), verify=False,stream=True)   #Note web_link is https://
r.raw.decode_content = True
with open("path", 'wb') as f:
    shutil.copyfileobj(r.raw, f)    
Python 3
import urllib.request
urllib.request.urlretrieve("web_link", "path")   
 
    
    
        Community
        
- 1
- 1
 
    
    
        Vineet Jain
        
- 1,515
- 4
- 21
- 31