zoukankan      html  css  js  c++  java
  • JxBrowser之五:清除cache和cookie以及SSL证书处理

    1、清除cache和cookie

            //清除cache
            browser.getCacheStorage().clearCache();
            browser.getLocalWebStorage().clear();
            browser.getSessionWebStorage().clear();
            //清除cookie
            CookieStorage cookieStorage = browser.getCookieStorage();
            List<Cookie> cookieList = cookieStorage.getAllCookies();
            for (Cookie cookie : cookieList) {
                if (cookie.getDomain().contains("baidu"))//根据需求进行配置
                    cookieStorage.delete(cookie);
            }
            cookieStorage.save(); //需要保存

     

    2、SSL证书处理

            BrowserContext browserContext = BrowserContext.defaultContext();
            NetworkService networkService = browserContext.getNetworkService();
            networkService.setCertificateVerifier(new CertificateVerifier() {
                @Override
                public CertificateVerifyResult verify(CertificateVerifyParams params) {
                    // Reject SSL certificate for all "baidu.com" hosts.
                    if (params.getHostName().contains("baidu.com")) { //根据需求进行域名修改
                        return CertificateVerifyResult.INVALID;
                    }
                    return CertificateVerifyResult.OK;
                }
            });

    以上。

  • 相关阅读:
    bzoj1818 [Cqoi2010]内部白点
    bzoj4001 [TJOI2015]概率论
    bzoj3997 [TJOI2015]组合数学
    bzoj3193 [JLOI2013]地形生成
    bzoj4869 [Shoi2017]相逢是问候
    bzoj4868 [Shoi2017]期末考试
    CF421D Bug in Code
    CCPC-WFinal-女生专场
    CF915F Imbalance Value of a Tree
    soj考试2
  • 原文地址:https://www.cnblogs.com/chevin/p/10029524.html
Copyright © 2011-2022 走看看