请问哪里出错了,谢谢

kk3239226441 2017-11-13 04:42:42
/**
*
*/
package com.crawl.zongheng;

import java.util.HashMap;
import com.util.RegexUtil;
import com.crawl.CrawlBase;
/**
* @author Administrator
*
*/
//提取某网站某本书的信息
public class IntroPage extends CrawlBase{
private String url;
private static HashMap<String,String> params;
private static final String AUTHOR ="<meta name=\"og:novel:author\" content=\"(.*?)\"/> ";
private static final String NAME="<meta name=\"og:novel:book_name\" content=\"(.*?)\"/> ";
private static final String DESC = "<meta property=\"og:description\" content=\"(.*?)\"/> ";
private static final String TYPE ="<meta name=\"og:novel:category\" content=\"(.*?)\"/>";
private static final String LASTCHAPTER ="<a class=\"chap\" href=\".*?\">(.*?)<p>";
private static final String WORDCOUNT ="<span title=\"(\\d*?)字\">";
private static final String KEYWORDS ="<div class=\"keyword\">(.*?)</div>";
private static final String KEYWORD ="<a.*?>(.*?)</a>";
private static final String CHAPTERLISTURL ="<meta name=\"og:novel:read_url\" content=\"(.*?)\"/>";

static{
params=new HashMap<String,String>();
params.put("Referer", "http://book.zongheng.com");
params.put("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.104 Safari/537.36 Core/1.53.4033.400 QQBrowser/9.6.12624.400");
params.put("Host","www.zongheng.com");
}
public IntroPage(String url){
readPageByget(url,params,"utf-8");
this.url=url;
}
/**
* @param args
*/
private String getName(){
return RegexUtil.getFirstString(getPageSourceCode(), NAME, 1);
}

private String getAuthor() {
return RegexUtil.getFirstString(getPageSourceCode(), AUTHOR, 1);
}

private String getDesc() {
return RegexUtil.getFirstString(getPageSourceCode(), DESC, 1);
}

private String getType() {
return RegexUtil.getFirstString(getPageSourceCode(), TYPE, 1);
}

private String getLastCharpter() {
return RegexUtil.getFirstString(getPageSourceCode(), LASTCHAPTER, 1);
}

private int getWordCount() {
String wordCount = RegexUtil.getFirstString(getPageSourceCode(), WORDCOUNT, 1);
return Integer.parseInt(wordCount.trim());
}

private String getKeyWordStr() {
return RegexUtil.getFirstString(getPageSourceCode(), KEYWORDS, 1);
}

private String getKeyWord() {
return RegexUtil.getString(getKeyWordStr(), KEYWORD, " ", 1);
}

private String getChapterListUrl() {
return RegexUtil.getFirstString(getPageSourceCode(), CHAPTERLISTURL, 1);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
IntroPage introPage = new IntroPage("http://book.zongheng.com/book/712549.html");
System.out.println(introPage.getName());
System.out.println(introPage.getAuthor());
System.out.println(introPage.getDesc());
System.out.println(introPage.getType());
System.out.println(introPage.getLastCharpter());
System.out.println(introPage.getWordCount());
System.out.println(introPage.getKeyWord());
System.out.println(introPage.getChapterListUrl());
}
}
输出结果以及报错是:

首先这些字符不知道为什么出现?还有应该有8个结果,可是我这里似乎只显示了5个。以及出现了其他异常。谢谢大神了。
...全文
436 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
当作看不见 2017-11-14
  • 打赏
  • 举报
回复
你发错地方了,应该发到Java 板块去的。
kk3239226441 2017-11-13
  • 打赏
  • 举报
回复
以上乱码问题已经解决,请问一下System.out.println(introPage.getWordCount());这个怎么错了,谢谢大神了。

2,760

社区成员

发帖
与我相关
我的任务
社区描述
搜索引擎的服务器通过网络搜索软件或网络登录等方式,将Internet上大量网站的页面信息收集到本地,经过加工处理建立信息数据库和索引数据库。
社区管理员
  • 搜索引擎技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧