Shardj
Shardj

Reputation: 1969

Py requests, 'No connection adapters were found'

  File "/usr/lib/python3/dist-packages/requests/api.py", line 67, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 53, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 570, in send
    adapter = self.get_adapter(url=request.url)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 644, in get_adapter
    raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for '"https://framework.zend.com/manual/1.12/en/manual.html"'

The url has https, and I've run a request from my terminal to this url with no issue so I'm lost as to why it can't find an adapter. I've looked into the source code and it's definitely there for https under default connection adapters

self.adapters = OrderedDict()
self.mount('https://', HTTPAdapter())
self.mount('http://', HTTPAdapter())

Thanks for any help

code:

def fetchUrl(self, url):
    response = requests.get(url, params=self.PAYLOAD)

and the payload

PAYLOAD = {
        'timeout': 60,
        'headers': {
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1'
        }
    }

Upvotes: 0

Views: 9007

Answers (1)

Nils Werner
Nils Werner

Reputation: 36765

You have superfluous quotes in your url parameter.

Look closely at the URL string in your error message, it says (pay attention to the quotes)

requests.exceptions.InvalidSchema: No connection adapters were found for '"https://framework.zend.com/manual/1.12/en/manual.html"'

when instead it should say

requests.exceptions.InvalidSchema: No connection adapters were found for 'https://framework.zend.com/manual/1.12/en/manual.html'

Upvotes: 4

Related Questions