當前位置: 首頁>>代碼示例>>Java>>正文


Java WebClient.getOptions方法代碼示例

本文整理匯總了Java中com.gargoylesoftware.htmlunit.WebClient.getOptions方法的典型用法代碼示例。如果您正苦於以下問題:Java WebClient.getOptions方法的具體用法?Java WebClient.getOptions怎麽用?Java WebClient.getOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.gargoylesoftware.htmlunit.WebClient的用法示例。


在下文中一共展示了WebClient.getOptions方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: helloWebClient

import com.gargoylesoftware.htmlunit.WebClient; //導入方法依賴的package包/類
public static void helloWebClient(WebClient client, WebClient jsclient) {
	final BrowserVersion browser = client.getBrowserVersion();
	System.out.println("ApplicationName: " + browser.getApplicationName());
	System.out.println("ApplicationCodeName: " + browser.getApplicationCodeName());
	System.out.println("ApplicationVersion: " + browser.getApplicationVersion());
	System.out.println("ApplicationMinorVersion: " + browser.getApplicationMinorVersion());
	System.out.println("BrowserLanguage: " + browser.getBrowserLanguage());
	System.out.println("BuildId: " + browser.getBuildId());
	System.out.println("CpuClass: " + browser.getCpuClass());
	System.out.println("CssAcceptHeader: " + browser.getCssAcceptHeader());
	System.out.println("HtmlAcceptHeader: " + browser.getHtmlAcceptHeader());
	System.out.println("ImgAcceptHeader: " + browser.getImgAcceptHeader());
	System.out.println("Nickname: " + browser.getNickname());
	System.out.println("Platform: " + browser.getPlatform());
	System.out.println("ScriptAcceptHeader: " + browser.getScriptAcceptHeader());
	System.out.println("SystemLanguage: " + browser.getSystemLanguage());
	System.out.println("UserAgent: " + browser.getUserAgent());
	System.out.println("UserLanguage: " + browser.getUserLanguage());
	System.out.println("Vendor: " + browser.getVendor());
	System.out.println("XmlHttpRequestAcceptHeader: " + browser.getXmlHttpRequestAcceptHeader());
	final int n = browser.getPlugins().size();
	int i = 0;
	System.out.println("Plugins(" + n + "):");
	for (PluginConfiguration pc : browser.getPlugins()) {
		i++;
		System.out.println(String.format(
				"  name=%s\n  version=%s\n  description=%s\n  filename=%s\n  mime-types=%s",
				pc.getName(),
				pc.getVersion(),
				pc.getDescription(),
				pc.getFilename(),
				Arrays.toString(pc.getMimeTypes().toArray())
		));
		if (i < n) {
			System.out.println(" --");
		}
	}

	final WebClientOptions clientOptions = client.getOptions();
	System.out.println("Timeout: " + clientOptions.getTimeout());
	System.out.println("MaxInMemory: " + clientOptions.getMaxInMemory());
	System.out.println("HistorySizeLimit: " + clientOptions.getHistorySizeLimit());
	System.out.println("HistoryPageCacheLimit: " + clientOptions.getHistoryPageCacheLimit());
	System.out.println("isActiveXNative: " + clientOptions.isActiveXNative());
	System.out.println("isAppletEnabled: " + clientOptions.isAppletEnabled());
	System.out.println("isCssEnabled: " + clientOptions.isCssEnabled());
	System.out.println("isDoNotTrackEnabled: " + clientOptions.isDoNotTrackEnabled());
	System.out.println("isDownloadImages: " + clientOptions.isDownloadImages());
	System.out.println("isGeolocationEnabled: " + clientOptions.isGeolocationEnabled());
	System.out.println(String.format(
			"isJavaScriptEnabled: %b | %b",
			clientOptions.isJavaScriptEnabled(),
			jsclient.getOptions().isJavaScriptEnabled()
	));
	System.out.println("isPopupBlockerEnabled: " + clientOptions.isPopupBlockerEnabled());
	System.out.println("isRedirectEnabled: " + clientOptions.isRedirectEnabled());
	System.out.println("isThrowExceptionOnFailingStatusCode: " + clientOptions.isThrowExceptionOnFailingStatusCode());
	System.out.println("isThrowExceptionOnScriptError: " + clientOptions.isThrowExceptionOnScriptError());
	System.out.println("isUseInsecureSSL: " + clientOptions.isUseInsecureSSL());
	System.out.print("\n");
}
 
開發者ID:limstepf,項目名稱:pdfdbscrap,代碼行數:62,代碼來源:Main.java

示例2: LinkedInOAuthRequestFilter

import com.gargoylesoftware.htmlunit.WebClient; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public LinkedInOAuthRequestFilter(OAuthParams oAuthParams, Map<String, Object> httpParams,
                                  boolean lazyAuth, String[] enabledProtocols) {

    this.oAuthParams = oAuthParams;
    this.oAuthToken = null;

    // create HtmlUnit client
    webClient = new WebClient(BrowserVersion.FIREFOX_38);
    final WebClientOptions options = webClient.getOptions();
    options.setRedirectEnabled(true);
    options.setJavaScriptEnabled(false);
    options.setThrowExceptionOnFailingStatusCode(true);
    options.setThrowExceptionOnScriptError(true);
    options.setPrintContentOnFailingStatusCode(LOG.isDebugEnabled());
    options.setSSLClientProtocols(enabledProtocols);

    // add HTTP proxy if set
    if (httpParams != null && httpParams.get(ConnRoutePNames.DEFAULT_PROXY) != null) {
        final HttpHost proxyHost = (HttpHost) httpParams.get(ConnRoutePNames.DEFAULT_PROXY);
        final Boolean socksProxy = (Boolean) httpParams.get("http.route.socks-proxy");
        final ProxyConfig proxyConfig = new ProxyConfig(proxyHost.getHostName(), proxyHost.getPort(),
            socksProxy != null ? socksProxy : false);
        options.setProxyConfig(proxyConfig);
    }

    // disable default gzip compression, as error pages are sent with no compression and htmlunit doesn't negotiate
    new WebConnectionWrapper(webClient) {
        @Override
        public WebResponse getResponse(WebRequest request) throws IOException {
            request.setAdditionalHeader(HttpHeaders.ACCEPT_ENCODING, "identity");
            return super.getResponse(request);
        }
    };

    if (!lazyAuth) {
        try {
            updateOAuthToken();
        } catch (IOException e) {
            throw new IllegalArgumentException(
                String.format("Error authorizing user %s: %s", oAuthParams.getUserName(), e.getMessage()), e);
        }
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:45,代碼來源:LinkedInOAuthRequestFilter.java


注:本文中的com.gargoylesoftware.htmlunit.WebClient.getOptions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。