class HostNameIgnoringAdapter(HTTPAdapter):

    def init_poolmanager(self, connections, maxsize, block=False):
        self.poolmanager = PoolManager(num_pools=connections, maxsize=
            maxsize, block=block, assert_hostname=False)


class CustomHostNameCheckingAdapter(HTTPAdapter):

    def cert_verify(self, conn, url, verify, cert):
        host = custom_function_mapping_url_to_hostname(url)
conn.assert_hostname = host
return super(CustomHostNameCheckingAdapter, self).cert_verify(conn, url,
    verify, cert)
Как отключить проверку имени хоста в запросах python