• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java WebWindow类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.gargoylesoftware.htmlunit.WebWindow的典型用法代码示例。如果您正苦于以下问题:Java WebWindow类的具体用法?Java WebWindow怎么用?Java WebWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WebWindow类属于com.gargoylesoftware.htmlunit包,在下文中一共展示了WebWindow类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: isAlreadyLoadedByAncestor

import com.gargoylesoftware.htmlunit.WebWindow; //导入依赖的package包/类
private boolean isAlreadyLoadedByAncestor(
                                           final URL url,
                                           HtmlPage page ) {

    WebWindow window = page.getEnclosingWindow();
    while (window != null) {
        if (url.sameFile(window.getEnclosedPage().getWebResponse().getWebRequest().getUrl())) {
            return true;
        }
        if (window == window.getParentWindow()) {
            window = null;
        } else {
            window = window.getParentWindow();
        }
    }
    return false;
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:18,代码来源:AbstractHtmlEngine.java


示例2: testPost

import com.gargoylesoftware.htmlunit.WebWindow; //导入依赖的package包/类
@Test
public void testPost() throws Exception {
	cfg.setProperty(WSFedConstants.PROP_USE_REDIRECT, false);

	StringWriter sw = new StringWriter();
	when(res.getWriter()).thenReturn(new PrintWriter(sw));
	
	LoginHandler lh = new LoginHandler();
	lh.handleGet(rc);
	
	WebWindow win = mock(WebWindow.class);
	when(win.getScriptObject()).thenThrow(new RuntimeException("test"));
	when(win.getWebClient()).thenReturn(new WebClient(BrowserVersion.FIREFOX_2));
	
	DOMParser parser = new DOMParser();
	parser.parse(new InputSource(new ByteArrayInputStream(sw.toString().getBytes())));
	HTMLElement e = (HTMLElement) parser.getDocument().getDocumentElement();
	
	NodeList forms = e.getElementsByTagName("form");
	assertEquals(1, forms.getLength());
	Element form = (Element)forms.item(0);
	assertEquals("loginform", form.getAttribute("name"));
	assertEquals(rc.getIdpMetadata().getFirstMetadata().getSingleSignonServiceLocation(WSFedConstants.WSFED_PROTOCOL), form.getAttribute("action"));
	
	verify(res, never()).sendRedirect(anyString());
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:27,代码来源:LoginHandlerTest.java


示例3: getValueByXpath

import com.gargoylesoftware.htmlunit.WebWindow; //导入依赖的package包/类
public static  void getValueByXpath(String url, String Xpath) throws MalformedURLException, IOException, XPatherException
{
	webClient.closeAllWindows();
	HtmlPage pg = null;
	try{
		pg = webClient.getPage(url);
	}catch(FailingHttpStatusCodeException exc){
		if(503 == exc.getStatusCode())
			System.out.println("ERRORXXXXHtmlUnit:  "+url);
		pg = webClient.getPage(url);
	}
	WebWindow win = webClient.getCurrentWindow();
	win.setInnerHeight(60000);
	List<?> result = null;
	result = pg.getByXPath(Xpath);
	for (int i=0; i<result.size();i++)
	System.out.println("qqq"+((HtmlElement) result.get(i)).getTextContent().trim());

}
 
开发者ID:anphoenix,项目名称:data_crawler_generic,代码行数:20,代码来源:ExtractInfoWithHtmlUnit.java


示例4: downloadCss

import com.gargoylesoftware.htmlunit.WebWindow; //导入依赖的package包/类
String downloadCss(WebClient webClient, WebWindow window, URL resourceUrl) throws Exception {
    if (cssjsCache.get(resourceUrl.toString()) == null) {
        cssjsCache.put(resourceUrl.toString(), webClient.getPage(window, new WebRequest(resourceUrl))
                .getWebResponse().getContentAsString());

    }
    return cssjsCache.get(resourceUrl.toString());
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:9,代码来源:ScreenCaptureHtmlUnitDriver.java


示例5: downloadImage

import com.gargoylesoftware.htmlunit.WebWindow; //导入依赖的package包/类
byte[] downloadImage(WebClient webClient, WebWindow window, URL resourceUrl) throws Exception {
    if (imagesCache.get(resourceUrl.toString()) == null) {
        imagesCache.put(
                resourceUrl.toString(),
                IOUtils.toByteArray(webClient.getPage(window, new WebRequest(resourceUrl)).getWebResponse()
                        .getContentAsStream()));
    }
    return imagesCache.get(resourceUrl.toString());
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:10,代码来源:ScreenCaptureHtmlUnitDriver.java


示例6: registerWindowAndMaybeStartEventLoop

import com.gargoylesoftware.htmlunit.WebWindow; //导入依赖的package包/类
/**
 * <p>This is turned into a NOOP if javascript is disabled, to stop the parent implementation from leaking threads
 * and memory.</p>
 * 
 * {@inheritDoc}
 */
@Override
public void registerWindowAndMaybeStartEventLoop(final WebWindow webWindow) {
    if (getWebClient().getOptions().isJavaScriptEnabled()) {
        super.registerWindowAndMaybeStartEventLoop(webWindow);
    }
}
 
开发者ID:forcedotcom,项目名称:SiteCrawler,代码行数:13,代码来源:EmptyJavascriptEngine.java


示例7: cleanUp

import com.gargoylesoftware.htmlunit.WebWindow; //导入依赖的package包/类
private void cleanUp() {
    Page p = page.get();
    if (p != null) {
        p.cleanUp();
    }
    for (WebWindow window : webClient.get().getWebWindows()) {
        window.getJobManager().removeAllJobs();
    }
    page.remove();
    webClient.get().close();
    webClient.remove();
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:13,代码来源:HtmlUnitRunStrategy.java


示例8: createPage

import com.gargoylesoftware.htmlunit.WebWindow; //导入依赖的package包/类
@Override
public Page createPage(WebResponse webResponse, WebWindow webWindow)
		throws IOException {
	String content = webResponse.getContentAsString();
	content = content.replaceAll(host, InetAddress.getLocalHost()
			.getHostAddress()
			+ ":" + Configuration.getInstance().getPort());
	return super.createPage(new WebResponse(new WebResponseData(content
			.getBytes(), webResponse.getStatusCode(), webResponse
			.getStatusMessage(), webResponse.getResponseHeaders()),
			webResponse.getWebRequest(), webResponse.getLoadTime()),
			webWindow);
}
 
开发者ID:vetsin,项目名称:SamlSnort,代码行数:14,代码来源:TestRunner.java


示例9: getPageInfoUseHtmlUnit

import com.gargoylesoftware.htmlunit.WebWindow; //导入依赖的package包/类
public void getPageInfoUseHtmlUnit(String url, JsonObject sourceConf) throws MalformedURLException, IOException, XPatherException
	{
		System.out.println("HtmlUnit:  "+url);
		webClient.closeAllWindows();
		HtmlPage pg = null;
		try{
			pg = webClient.getPage(url);
		}catch(FailingHttpStatusCodeException exc){
			if(503 == exc.getStatusCode())
			{	System.out.println("ERRORXXXXHtmlUnit:  "+url);
				try{
				pg = webClient.getPage(url);
				} catch(Exception e)
				{
					return;
				}
			}
			return ;
		}
		WebWindow win = webClient.getCurrentWindow();
		win.setInnerHeight(60000);
		
		JsonObject info = sourceConf.get("info_extractor").getAsJsonObject();
		String save_name = sourceConf.get(ConfConstants.SOURCE_SAVE_NAME).getAsString();
		JsonObject qa = new JsonObject();
		List<?> temp = null;
		for(Entry<String, JsonElement> entry: info.entrySet())
		{
			temp = pg.getByXPath(entry.getValue().getAsString());
			String result = "";
			if(temp.size() > 0)
			{
				result = ((HtmlElement) temp.get(0)).getTextContent().trim();
				if(entry.getKey().equals(ConfConstants.SOURCE_INFO_DATE))
				{
					result = CommonUtil.getDateString(result,".*?([0-9]+.[0-9]+.[0-9]+).*");
//					String format = sourceConf.get(ConfConstants.SOURCE_DATE_FORMAT).getAsString();
//					result = (CommonUtil.stringToDateByconf(result, format)).toString();
				}
				qa.addProperty(entry.getKey(), CommonUtil.cleanString(result));
			}
		}
		qa.addProperty(ConfConstants.SOURCE_URL, url);
		if(qa.has(ConfConstants.SOURCE_INFO_REPLY_TITLE)||qa.has(ConfConstants.SOURCE_INFO_REPLY_CONTENT))
			CommonUtil.saveContent(CommonUtil.cleanString(qa.toString())+"\n", SysConf.SAVE_PATH+save_name+".txt");
	}
 
开发者ID:anphoenix,项目名称:data_crawler_generic,代码行数:47,代码来源:ExtractInfoWithHtmlUnit.java



注:本文中的com.gargoylesoftware.htmlunit.WebWindow类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HintUtil类代码示例发布时间:2022-05-22
下一篇:
Java VisitResult类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap