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
相关文档:
如何表示上级目录
../表示源文件所在目录的上一级目录,../../表示源文件所在目录的上上级目录,以此类推。
假设info.html路径是:c:\Inetpub\wwwroot\sites\blabla\info.html
假设index.html路径是:c:\Inetpub\wwwroot\sites\index.html
在info.html加入index.html超链接的代码应该这样写:
<a href ......
如果用webbrowser的document去获取IFrame这个对象,随后一定会得到accessdenied的错误,为什么?
找了一下,据说是不能跨域访问...
终于有一天,试了一下,在OnDocumentComplete事件里面返回的dispatch就是iframe的IHTMLWindow2对象,在那里可以操作所有的对象,然后,你想做什么就随你了,不知道如果这个时候保存了这个I ......
<html>
<head>
<script>
function locking(){
document.all.ly.style.display="block";
document.all.ly.style.width=document.body.clientWidth;
document.all.ly.style.height ......
根据剪贴板的原理,在获取剪贴板内容之前,必须指定要获取内容的格式。由于剪贴板中的数据可能存在多种格式,所以有必要对剪贴板的格式类型先做一些了解。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">
......