首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

下面两段parser相关的代码哪里出了有关问题,为何不能运行通过

2013-04-02 
下面两段parser相关的代码哪里出了问题,为何不能运行通过?我在写robot爬虫的代码的时候发现下面两个标注有

下面两段parser相关的代码哪里出了问题,为何不能运行通过?
我在写robot爬虫的代码的时候发现下面两个标注有问题的代码要是写上去的话,就不能正常运行,注释掉的话,运行是正常运行,但是最后显示的结果是找到的关键字数为0, 但不应该是0

public void processHtml(String url) throws ParserException, Exception 
{
searchedsite.add(url);
count = 0;
System.out.println("searching ... :" + url);
System.out.println(url);

parser.setURL(url);// 有问题
parser.setEncoding("GBK");
URLConnection uc = parser.getConnection();
// uc.connect(); 有问题
//uc.getLastModified();
NodeIterator nit = parser.elements();

while (nit.hasMoreNodes()) 
{
Node node = nit.nextNode();
parserNode(node);
}
srb.setKeywords(keyword);
srb.setUrl(url);
srb.setCount_key_words(count);
resultlist.add(srb);
System.out.println("count keywords is :" + count);
System.out.println("----------------------------------------------");
}
[解决办法]
parser在哪里定义的
[解决办法]
Connection refused: connect拒绝连接了,没有权限啊

热点排行