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


Java Page.getWebResponse方法代碼示例

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


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

示例1: getDocumentWithoutGateway

import com.gargoylesoftware.htmlunit.Page; //導入方法依賴的package包/類
private static DownloadableDocument getDocumentWithoutGateway(Page directDownloadPage, String courseName, Term term) {
    String downloadPageURL = directDownloadPage.getUrl().toString();
    WebResponse response = directDownloadPage.getWebResponse();
    String contentDispositionHeader = response.getResponseHeaderValue("Content-Disposition");
    String filename = fetchFileNameFromContentDisposition(contentDispositionHeader);
    String extension = fetchFileExtension(filename);
    String name = filename.substring(0, filename.indexOf(extension));
    long size = fetchFileSizeFromResponse(response);

    //todo find better solution for the zip-name hack
    if (ZIP_EXTENSION.equals(extension)) {
        name = clearZIPName(name);
        name += "-" + size;
    }
    return new DownloadableDocument(name, downloadPageURL, courseName, extension, size, term);
}
 
開發者ID:theovier,項目名稱:lernplattform-crawler,代碼行數:17,代碼來源:DocumentCrawler.java

示例2: checkForServerError

import com.gargoylesoftware.htmlunit.Page; //導入方法依賴的package包/類
private static void checkForServerError(final Page page) throws IOException {
  final com.gargoylesoftware.htmlunit.WebResponse response = page.getWebResponse();
  final int code = response.getStatusCode();
  final boolean error;
  if (code >= 400) {
    error = true;
  } else {
    error = false;
  }
  if (error) {
    final String responseMessage = response.getStatusMessage();
    final String text = getPageSource(page);
    final File output = File.createTempFile("server-error", ".html", new File("screenshots"));
    final FileWriter writer = new FileWriter(output);
    writer.write(text);
    writer.close();
    Assert.fail("Error loading page: "
        + page.getUrl() + " code: " + code + " message: " + responseMessage + " Contents of error page written to: "
        + output.getAbsolutePath());
  }

}
 
開發者ID:jpschewe,項目名稱:fll-sw,代碼行數:23,代碼來源:WebTestUtils.java

示例3: saveDocument

import com.gargoylesoftware.htmlunit.Page; //導入方法依賴的package包/類
private void saveDocument(DownloadableDocument document, Path target) throws IOException {
    Page downloadPage = browser.getPage(document.getDownloadLink());
    WebResponse response = downloadPage.getWebResponse();
    document.setSize(response.getContentLength());
    try (CountingInputStream in = new CountingInputStream(response.getContentAsStream())) {
        copy(in, target, document);
    }
}
 
開發者ID:theovier,項目名稱:lernplattform-crawler,代碼行數:9,代碼來源:DownloadSlave.java

示例4: readURL

import com.gargoylesoftware.htmlunit.Page; //導入方法依賴的package包/類
@Override
protected Set<Validatable> readURL(LineFormater formater, MyHttpClient<?, ?> httpcx) throws HttpException, IOException {
	
	@SuppressWarnings("unchecked")
	MyHttpClient<String, Page> httpcxCast = (MyHttpClient<String, Page> ) httpcx;
	Page page = httpcxCast.doCall(this.getRequestMethod(formater.getMyUrl()));
	WebResponse webResponse = page.getWebResponse();
	
	return super.parseInputStream(webResponse.getContentAsStream(), formater, new ArrayList<>()); 
	
}
 
開發者ID:premiummarkets,項目名稱:pm,代碼行數:12,代碼來源:HttpSourceAspScrapper.java


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