__init__.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:ceiba-dl 作者: lantw44 项目源码 文件源码
def __init__(self, api_cookies, web_cookies, cipher=None, api_args={'api': '1'},
        api_url='https://ceiba.ntu.edu.tw/course/f03067/app/login.php',
        file_url='https://ceiba.ntu.edu.tw',
        web_url='https://ceiba.ntu.edu.tw'):

        self.logger = logging.getLogger(__name__)
        self.curl = pycurl.Curl()
        self.api_cookie = ';'.join(map(lambda x: '{}={}'.format(*x), api_cookies.items()))
        self.web_cookie = ';'.join(map(lambda x: '{}={}'.format(*x), web_cookies.items()))
        self.api_args = api_args
        self.api_url = api_url
        self.file_url = file_url
        self.web_url = web_url
        self.api_cache = None
        self.web_cache = dict()
        if not cipher:
            tls_backend = pycurl.version_info()[5].split('/')[0]
            if tls_backend == 'OpenSSL':
                cipher = 'AES128-SHA'
            elif tls_backend == 'GnuTLS':
                cipher = 'AES128-SHA'
            elif tls_backend == 'NSS':
                cipher = 'rsa_aes_128_sha'
            else:
                assert False, 'TLS ?? {} ????'.format(tls_backend)
        self.curl.setopt(pycurl.USE_SSL, pycurl.USESSL_ALL)
        self.curl.setopt(pycurl.SSL_CIPHER_LIST, cipher)
        self.curl.setopt(pycurl.PROTOCOLS, pycurl.PROTO_HTTPS)
        self.curl.setopt(pycurl.REDIR_PROTOCOLS, pycurl.PROTO_HTTPS)
        self.curl.setopt(pycurl.DEFAULT_PROTOCOL, 'https')
        self.curl.setopt(pycurl.FOLLOWLOCATION, False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号