6

I want to download a file from my server using the https protocol. How should I go about doing this? This is my basic code with http

response=requests.get('http://url',stream='True')

handle=open('dest_file.txt','wb')
for chunk in response.iter_content(chunk_size=512):
    if chunk:  # filter out keep-alive new chunks
        handle.write(chunk)

handle.close()  

can the requests module be used for https as well?

James Schinner
  • 1,549
  • 18
  • 28

1 Answers1

4

According to http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification

response=requests.get('https://url', stream='True', verify='your certificate.crt')

handle=open('dest_file.txt','wb')
for chunk in response.iter_content(chunk_size=512):
    if chunk:  # filter out keep-alive new chunks
        handle.write(chunk)

handle.close()  
Wilhelm Liao
  • 829
  • 5
  • 12