1

I have already written a script that will take an .xlsm file and will update this file based on some other file and then will plot a graph according to the updated data. The Script is working fine. But now as this script is contributing to automation of a process,it needs to get the Excel(.xlsm) file from a url and then update the file and may be save it back to the same url.

I have tried downloading the file into a local copy using below code-

import requests

url = 'https://sharepoint.amr.ith.intel.com/sites/SKX/patchboard/Shared%20Documents/Forms/AllItems.aspx?RootFolder=%2Fsites%2FSKX%2Fpatchboard%2FShared%20Documents%2FReleaseInfo&FolderCTID=0x0120004C1C8CCA66D8D94FB4D7A0D2F56A8DB7&View={859827EF-6A11-4AD6-BD42-23F385D43AD6}/Copy of Patch_Release_Utilization'
r = requests.get(url)
open('Excel.xlsm', 'wb').write(r.content)

By doing this I am getting the error-

Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)'),)

What I understood till now is that the Server is not sending the complete Chain Certificates to the browser for authentication.

I also tried-

r=requests.get(url,verify=False)

By doing this error is gone but The file created is empty.When I checked status code for the connection using code-

r=requests.get(url,verify=False).status_code

I got the code as "401" which means authorization error.I have tried providing authentication as-

resp = requests.get(url,auth=HTTPBasicAuth('username', 'password'),verify=False)
               and
resp = requests.get(url,auth=HTTPBasicAuth('username', 'password'))

both the above lines I have tried but still status code remained same. Then I came along an article-Python requests SSL error - certificate verify failed ,where the author is asking to add missing certificates in a .pem file then use that pem file.How to know what are the missing certificates??So din't get any help from there also.

Can somebody please help me with this if somebody already catered this problem.It will be a great help.I am using Python3.6.3 and requests version is 2.18.4

NOTE- When i am using the link manually on Internet Explorer I am able to download the file

rikki
  • 431
  • 1
  • 8
  • 18
  • [Edit] your Question and add Python, requests and OS Versions. There is no `https://sharepoint.amr.ith.intel.com`, checked with `host https://sharepoint.amr.ith.intel.com` gives `Host https://sharepoint.amr.ith.intel.com not found: 3(NXDOMAIN)`. [ssllabs.com/ssltest](https://www.ssllabs.com/ssltest/analyze.html?d=sharepoint.amr.ith.intel.com) result in **Unable to resolve domain name**. – stovfl Oct 09 '18 at 19:23
  • May be you are not able to use the domain because this requires some access or something because this is company's sharepoint.I don't think evryone can access it.Moreover when I am using this link on Internet explorer the browser gives me option for downloading the filethat means it is working properly manually.What can be the problem then??-@stovfl – rikki Oct 10 '18 at 05:37
  • `requests` behave not like **IE**. Break down your problem to **first** get succesfull the login page. Therefore use **only** `r=requests.get('https://sharepoint.amr.ith.intel.com')`, without `auth=`. [Edit] your Question and add the output of `print(r.headers)`. I assume the **SSL Error** persists, therefore your **OS Version** are relevant. – stovfl Oct 10 '18 at 06:14

0 Answers0