votes up 1

Please check proxy URL. It is malformed and could be missing the host.

Package:
Exception Class:
InvalidProxyURL

Raise code

    proxy = select_proxy(url, proxies)

        if proxy:
            proxy = prepend_scheme_if_needed(proxy, 'http')
            proxy_url = parse_url(proxy)
            if not proxy_url.host:
                raise InvalidProxyURL("Please check proxy URL. It is malformed"
                                      " and could be missing the host.")
            proxy_manager = self.proxy_manager_for(proxy)
            conn = proxy_manager.connection_from_url(url)
        else:
            # Only scheme should be lower case
            parsed = urlparse(url)
            url = parsed.geturl()
            conn
😲 Agile task management is now easier than calling a taxi. #Tracklify

Ways to fix

votes up 0 votes down

When you passing proxy configuration for requests library make sure URL of proxy server is valid.

Example how to reproduce exception (WRONG CODE):

import requests

proxies = {
  'http''http://:80',  # <-- error is here: URL
}

resp = requests.get('http://fixexception.com', proxies=proxies)
print('Response status:', resp.status_code)

Examples of right URLs (Fixed exception):

import requests

proxies = {
  'http''http://202.83.125.254:80', # < -- good URL😉
}

resp = requests.get('http://fixexception.com', proxies=proxies)
print('Response status:', resp.status_code)

Criteria of correct URL

Url checked in urllib3 parse against regexp:

_URI_RE = re.compile(
	    r"^(?:([a-zA-Z][a-zA-Z0-9+.-]*):)?"
	    r"(?://([^\\/?#]*))?"
	    r"([^?#]*)"
	    r"(?:\?([^#]*))?"
	    r"(?:#(.*))?$",
	    re.UNICODE | re.DOTALL,
	)

You can read more about how it gets host here 😉

May 17, 2021 ivictbor answer

Add a possible fix

Please authorize to post fix