from twisted.internet._sslverify import ClientTLSOptions
from scrapy.core.downloader.contextfactory import ScrapyClientContextFactory


class CustomClientContextFactory(ScrapyClientContextFactory):

    def getContext(self, hostname=None, port=None):
        ctx = ClientContextFactory.getContext(self)
ctx.set_options(SSL.OP_ALL)
if hostname:
    ClientTLSOptions(hostname, ctx)
return ctx
Crawling SSL site with scrapy