当前位置: 首页>>代码示例>>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;未经允许,请勿转载。