# coding: utf-8 """ 绕过 JA3指纹反爬机制 参考:https://mp.weixin.qq.com/s/tuZScT0qVwPl6bQewqz0zg """ import random import ssl # ssl._create_default_https_context = ssl._create_unverified_context ORIGIN_CIPHERS = ('ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+HIGH:' 'DH+HIGH:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+HIGH:RSA+3DES') class SSLFactory: def __init__(self): self.ciphers = ORIGIN_CIPHERS.split(":") def __call__(self) -> ssl.SSLContext: random.shuffle(self.ciphers) ciphers = ":".join(self.ciphers) ciphers = ciphers + ":!aNULL:!eNULL:!MD5" context = ssl.create_default_context() context.set_ciphers(ciphers) return context ssl_gen = SSLFactory()