本文整理汇总了Java中com.meterware.httpunit.WebResponse.getLinks方法的典型用法代码示例。如果您正苦于以下问题:Java WebResponse.getLinks方法的具体用法?Java WebResponse.getLinks怎么用?Java WebResponse.getLinks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.meterware.httpunit.WebResponse
的用法示例。
在下文中一共展示了WebResponse.getLinks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findURLInAHREF
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
private static String findURLInAHREF(WebResponse resp, String linkSubstring) throws SAXException {
WebLink[] links = resp.getLinks();
if (links != null) {
for (WebLink link : links) {
MockLearner.log.debug("Checking link " + link.getURLString());
if (link.getURLString().indexOf(linkSubstring) != -1) {
return link.getURLString();
}
}
}
return null;
}
示例2: processLinks
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
/**
* @param resp
* @param i
* @param maxDepth
* @throws SAXException
* @throws IOException
*/
private void processLinks(WebResponse resp, int i, int maxDepth) throws SAXException, IOException
{
char[] p = new char[i];
for (int j = 0; j < i; j++)
{
p[j] = ' ';
}
String pad = new String(p);
WebLink[] links = resp.getLinks();
for (WebLink link : links)
{
String url = link.getURLString();
if (visited.get(url) == null)
{
visited.put(url, url);
if (isLocal(url))
{
log.info("Getting " + pad + link.getURLString());
WebResponse response = null;
try
{
response = link.click();
}
catch (HttpException ex)
{
log.warn("Failed to get Link " + url + " code:"
+ ex.getResponseCode() + " cause:"
+ ex.getResponseMessage());
}
catch (ConnectException cex)
{
log.error("Failed to get Connection to "+url);
}
if (response != null)
{
clickAll(response, i, maxDepth);
}
}
else
{
log.info("Ignoring External URL " + url);
}
}
}
}