Python - How to add NTLM Authentication in Requests_HTML?

25 Views Asked by At

I want to pass an Authentication object when creating a get request in requests_html. Also want to pass a file path for the certificate. This is what I have so far.

def get_url():
     s = HTMLSession()
     try:
         response = s.get(url)
     except Exception as e:
         logging.exception('Could not send get request: {}'.format(e))
     response.html.render()
     return response
1

There are 1 best solutions below

0
Rafael Castillo On

To pass an Authentication object and a file path for the certificate when creating a get request in requests_html, you can use the auth and verify keyword arguments, respectively. Here is an example of how to do this:

import requests_html

def get_url():
    s = HTMLSession()
    try:
        response = s.get(url, auth=auth, verify=cert_path)
    except Exception as e:
        logging.exception('Could not send get request: {}'.format(e))
    response.html.render()
    return response

In this example, auth is an Authentication object and cert_path is the file path to the certificate.