I am writing a python script that will save the pdf file locally according to the format specified in the url. eg.
https://Hostname/saveReport/file_name.pdf
I open this url through a python script:
import webbrowser webbrowser.open("https://Hostname/saveReport/file_name.pdf")
The url contains a lot of images and text. Once this URL is open, I want to save the pdf file using a python script.
This is what I have done so far. Code 1:
import requests url="https://Hostname/saveReport/file_name.pdf"
Code 2:
import urllib2 import ssl url="https://Hostname/saveReport/file_name.pdf" context = ssl._create_unverified_context() response = urllib2.urlopen(url, context=context)
In the above code, I get: urllib2.HTTPError: HTTP error 401: unauthorized
If I use code 2, how can I transfer authorization data?
user3439895
source share