lucene 索引HTML文档
深未来技术
1、大部分WEB文档采用HTML格式。
2、本例用如下HTML文档
<html>
<head>
<title>
Laptop power supplies are avaliable in First class only
</title>
</head>
<body>
<h1>code,write,fly</h1>
</body>
</html>
3、使用JTidy
JTidy由Andy Quick编写的Tidy的Java版本。
public class JTidyHTMLHandler implements DocumentHandler{
publicorg.apache.lucene.document.Document getDocument(InputStreamis)
throwsDocumentHandlerException{ //传入一个代表HTML文档的InputStream对象
Tidy tidy=new Tidy();
tidy.setQuiet(true);
tidy.setShowWarnings(false);
//解析代表HTML文档的InputStream对象
org.w3c.dom.Documentroot=tidy.parseDOM(is,null);
ElementrawDoc=root.getDocumentElement();
org.apache.lucene.document.Document doc=neworg.apache.lucene.document.Document();
Stringtitle=getTitle(rawDoc);//获得标题
Stringbody=getBody(rawDoc);//获得<body>和</body>之间所有元素
if((title!=null)&&(!title.equals(""))) {
doc.add(Field.Text("title",title));
}
if((body!=null)&&(!body.equals(""))){
doc.add(Field.Text("body",body));
}
return doc;
}
protected String getTitle(Element rawDoc){
if(rawDoc==null){
returnnull;
}
Stringtitle="";
NodeListchildren=rawDoc.getElementsB
相关文档:
根据剪贴板的原理,在获取剪贴板内容之前,必须指定要获取内容的格式。由于剪贴板中的数据可能存在多种格式,所以有必要对剪贴板的格式类型先做一些了解。W写下了以下的测试代码:
procedure TForm1.Button3Click(Sender: TObject);
var
i: integer;
Buffer: PChar;
s: string;
begin
M ......
<html>
<frameset rows="10%,*">
<frame src="http://g.cn" scrolling="no">
<frameset cols="25%,*">
<frame src="http://g.cn" scrolling="no">
<frameset rows="10%,*">
<frame src="http://g.cn" scrolling="no">
......
<html>
<script language="javascript" defer>
function isvalid()
{
Input_Str=document.getElementById("tsinput").value;
document.getElementById("ts").innerHTML=Input_Str;
if(Input_Str!=document.getElementById("ts").innerText)
alert("include Html Element... ......
Window 对象
Window 对象是 JavaScript 层级中的顶层对象。
Window 对象代表一个浏览器窗口或一个框架。
Window 对象会在 <body> 或 <frameset> 每次出现时被自动创建。
有关 Window 对象的详细描述。
IE: Internet Explorer, F: Firefox, O: Opera.
Window 对象的集合
CollectionDescriptionIEFO
fr ......