4

I'm trying to login and scrape an airline website with the python Request package. I am getting the belowe error just by trying to load the main website. This code use to work last year but I have not tried it until now with the new Requests 2.2.1. Any ideas what is going on?

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:547)

I'm using Requests 2.2.1.

ssladapter.py

from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager

from ssl import PROTOCOL_TLSv1


class SSLAdapter(HTTPAdapter):
    '''An HTTPS Transport Adapter that uses an arbitrary SSL version.'''

    __attrs__ = ['max_retries', 'config', '_pool_connections', '_pool_maxsize', '_pool_block', 'ssl_version']

def __init__(self, ssl_version=None, **kwargs):
    self.ssl_version = ssl_version

    super(SSLAdapter, self).__init__(**kwargs)


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

scrape.py

import requests
import ssladapter
from ssl import PROTOCOL_TLSv1

session = requests.Session()
session.mount('https://', ssladapter.SSLAdapter(ssl_version=PROTOCOL_TLSv1))

request = session.get("www.delta.com")

!!! SSLERROR raised here.

fat fantasma
  • 7,483
  • 15
  • 48
  • 66

1 Answers1

1

This Error is not a problem of the Requests library because it has been rigorously tested.

This is an indication of a 'Man-in-the-middle' attack.

May be you may be having a Network Sniffing tool like Fiddler or Wireshark running.

More Detailed Info on this a related Question Here it is suggested that this is how SSL should work.

Community
  • 1
  • 1
Rishit
  • 11
  • 2