engine

原创 2005年03月01日 22:19:00


/*
 该程序模拟搜索引擎的实现过程。用本程序接受搜索引擎搜索到的结果
 然后对字符串进行处理,最后在输出页面给用户。

 */
package common.engine;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.regex.*;
public class Engine extends HttpServlet {

    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException,ServletException {
        String strStartPage="";
        String strName;
        int m=0;
        byte[] buffer=new byte[2500];
        String temp="";
        InputStream input=null;
        String www="href='/DaLianNetWeb/engine";
        strName=(String)request.getParameter("word");
        strStartPage=request.getParameter("page");
       
     
     //   byte[] strkkk=strName.getBytes("ISO8859-1");
    
//        byte[] strkkk=strName.getBytes("iso8859-1","gb2312");       
//        String strKEY=new String(strkkk);

       strName=new String(strName.getBytes("iso8859-1"),"gb2312");
       String strKEY;
       strKEY=strName;
      
        ServletOutputStream ow=response.getOutputStream();
        OutputStreamWriter out=new OutputStreamWriter(ow,"GB2312");
        out.write("<!DOCTYPE HTML PUBLIC /"-//W3C//DTD HTML 4.01 Transitional//EN/" /"http://www.w3.org/TR/html4/loose.dtd/">");
        out.write("<html><head>");
        out.write("<meta http-equiv=/"Content-Type/" content=/"text/html; charset=gb2312/">");
        out.write("<title>大连网搜索</title>");
        out.write("<link href=/"../DaLianNetWeb/common/css/css.css/" rel=/"stylesheet/" type=/"text/css/">");
        out.write("</head><body>");
        out.write("<table width=/"777/" height=/"115/" border=/"0/" cellpadding=/"0/" cellspacing=/"0/" id=/"search-list/">");
        out.write("<tr><td width=/"198/" height=/"71/"><img src=/"../DaLianNetWeb/common/images/logo2.gif/" width=/"198/" height=/"71/"></td>");
        out.write("<td width=/"579/" valign=/"top/" class=/"top-center-1/"><table border=/"0/" cellpadding=/"0/" cellspacing=/"0/" id=/"top-nav/">");
        out.write("<tr><td><a href=/"/DaLianNetWeb/index.html/">网站首页</a></td>");
        out.write("<td><a href=/"/DaLianNetWeb/NetSys/zhineng.htm/">中心简介</a></td>");
        out.write("<td><a href=/"/DaLianNetWeb/Special/zhuantifagui1.html/">行业指导</a></td>");
        out.write("<td><a href=/"/DaLianNetWeb/Special/index.html/">专题资源</a></td>");
        out.write("<td><a href=/"#/">公共数据</a></td>");
        out.write("<td><a href=/"/DaLianNetWeb/search.htm/">大连导航</a></td>");
        out.write("</tr></table></td></tr>");
        out.write("<tr> <td height=/"44/" colspan=/"2/"><table width=/"100%/" border=/"0/" cellpadding=/"0/" cellspacing=/"0/">");
        out.write("<tr><td width=/"637/" height=/"34/" class=/"nav/">");
        out.write("<form name=f1 action=/DaLianNetWeb/engine>");
        out.write(" <div align=/"center/">");
        out.write("<input type=/"text/" name=/"word/" value="+strKEY+" >");//修改
        out.write("&nbsp;&nbsp;&nbsp;");
        out.write("<input type=/"submit/" name=/"Submit/" value=/"大连网搜索/"> ");//修改
        out.write("&nbsp;&nbsp;&nbsp;");
        out.write("<input type=/"submit/" name=/"Submit2/" value=/"在结果中搜索/"> ");
        out.write("</div>");
        out.write("</form>");
        out.write("</td> </tr></table></td></tr></table>");
        out.write("<table width=/"922/"  border=/"0/" cellpadding=/"0/" cellspacing=/"0/" class=/"center-table/" id=/"search-list/">");
        out.write("<tr><td height=/"315/">");
      try{
          URL hp = new URL("http://www.baidu.com/baidu?word=" + strKEY +
                           "&rn=10&pn=" + strStartPage + "");
          URLConnection hpCon = hp.openConnection();
          input = hpCon.getInputStream();
          StringBuffer strTemp = new StringBuffer();
          while ( (m = input.read(buffer, 0, 2500)) != -1) {
            strTemp.append(new String(buffer, 0, m));
          }
          strTemp.delete(0, strTemp.indexOf("<p class=p2>"));
          strTemp.delete(strTemp.lastIndexOf("<br clear=all>"),
                         strTemp.lastIndexOf("</table>"));
          temp = new String(strTemp);
          Pattern pat1 = Pattern.compile("<font  color=/"#666666/">.*?上的更多结果");
          Matcher mc1 = pat1.matcher(temp);
          temp = mc1.replaceAll("");
          Pattern pat2 = Pattern.compile("<font color=#008000>.*?百度快照");
          Matcher mc2 = pat2.matcher(temp);
          temp = mc2.replaceAll("");
          Pattern pat3 = Pattern.compile("color=#008000>.*?推广");
          Matcher mc3 = pat3.matcher(temp);
          temp = mc3.replaceAll("");

          out.write("<table width='95%'><tr><td>" + temp + "</td></tr></table>");
          out.write(" <div align=/"center/">");
          out.write("<A " + www + "?&word=" + strKEY +
                    "&rn=10&page=0'>[1]</A>&nbsp");
          out.write("<A " + www + "?&word=" + strKEY +
                    "&rn=10&page=10'>[2]</A>&nbsp");
          out.write("<A " + www + "?&word=" + strKEY +
                    "&rn=10&page=20'>[3]</A>&nbsp");
          out.write("<A " + www + "?&word=" + strKEY +
                    "&rn=10&page=30'>[4]</A>&nbsp");
          out.write("<A " + www + "?&word=" + strKEY +
                    "&rn=10&page=40'>[5]</A>&nbsp");
          out.write("<A " + www + "?&word=" + strKEY +
                    "&rn=10&page=50'>[6]</A>&nbsp");
          out.write("<A " + www + "?&word=" + strKEY +
                    "&rn=10&page=60'>[7]</A>&nbsp");
          out.write("<A " + www + "?&word=" + strKEY +
                    "&rn=10&page=70'>[8]</A>&nbsp");
          out.write("<A " + www + "?&word=" + strKEY +
                    "&rn=10&page=80'>[9]</A>&nbsp");
          out.write("<A " + www + "?&word=" + strKEY +
                    "&rn=10&page=90'>[10]</A>&nbsp");
          out.write("<A " + www + "?&word=" + strKEY +
                    "&rn=10&page=100'>下一页</A>&nbsp");
          out.write("</div>");
          out.write("</td></tr></table>");
          out.write(
              "<table border=/"0/" cellpadding=/"0/" cellspacing=/"0/" id=/"bottom-table/">");
          out.write(
              "<tr><td height=/"34/"><p><strong>大连市信息资源管理中心版权所有</strong></p></td>");
          out.write("</tr>");
          out.write("<tr>");
          out.write("<td>--------- <a href=/"/DaLianNetWeb/NetSys/friend.html/">合作伙伴 </a>"+
                    "<a href=/"/DaLianNetWeb/NetSys/copyright.html/">版权声明 </a>"+
                    "<a href=/"/DaLianNetWeb/NetSys/wangzhan.html/">网站简介 </a>"+
                    "<a href=/"/DaLianNetWeb/NetSys/law.html/">法律声明 </a>"+
                    "<a href=/"/DaLianNetWeb/NetSys/zhineng.htm/">用户指南 </a> "+
                    "---------<span class=/"style5/"></span></td>");
          out.write(" </tr>");
          out.write("</table>");
          out.write("</body>");
          out.write("</html>");
          input.close();

       }catch(Exception e){

          out.write("没有查询结果!");
        }
          out.close();
          ow.close();
    }
 }

Mysql 中的 table engine ,及各种engine的区别和作用

...
  • tankejin
  • tankejin
  • 2006-12-30 15:00:00
  • 16272

MySql -- 创建表时 engine=innodb和engine=myisam的区别

创建数据库表时数据存储引擎   engine两种:engine=innodb和engine=myisam 1、myisam,默认类型。是存储记录和文件的标准类型,支持全文搜索,可以被压缩,与其他引擎...
  • u010286334
  • u010286334
  • 2015-06-15 09:32:22
  • 554

Cheat Engine破解妙用之一

本篇不用于任何商业活动,属于偷懒省钱小技巧,应朋友需求写下这个小技巧 1.首先运行CE和百度云,切换到CE界面,点击电脑图标 2.找到百度云运行程序,选中后,点击open(打开) 3.使...
  • qq_34819372
  • qq_34819372
  • 2017-08-09 10:11:30
  • 1011

wallpaper Engine 安装教程

今天在网上看到了一个软件wallpaper Engine。效果太酷炫了。就买了个来试试,效果是很棒。但是缺点是无法和桌面管理工具兼容,例如Fences,如果要二者兼得,则必须要PS辅助。 运...
  • HughGilbert
  • HughGilbert
  • 2017-01-06 21:58:31
  • 1407

[Game Engine]开源游戏框架(转至wiki)

   Agar - 一个高级图形应用程序框架,用于2D和3D游戏。Allegro - 基于 C/C++ 的游戏引擎,支持图形,声音,输入,游戏时钟,浮点,压缩文件以及G...
  • huodianyan
  • huodianyan
  • 2014-09-29 08:17:56
  • 1156

Google Earth Engine简介

Google Earth Engine(GEE)是Google提供的对大量全球尺度地球科学资料(尤其是卫星数据)进行在线可视化计算分析处理的平台,未来地球科学的大杀器啊。链接:https://eart...
  • dou3516
  • dou3516
  • 2017-09-07 07:54:28
  • 3500

使用Cheat Engine实现单机游戏作弊

使用工具: (1)Cheat Engine,dll注入工具,C/C++开发环境(vs2015) 步骤: (1)打开所要修改的单机游戏,运行起来。 (2)打开Cheat Engine软件,找到运...
  • u014220852
  • u014220852
  • 2017-01-10 20:24:13
  • 585

Cheat Engine使用记录(一)精确数字的查找

最近绝地求生游戏大热,同时外挂也如雨后春笋一般到处都是,作为一个学计算机的的学生,在享受游戏的过程中,被各种外挂搞得哭爹喊娘,实在是不服气,于是对游戏外挂产生了兴趣,于是便接触到了CE,能对游戏进程的...
  • qq_36425506
  • qq_36425506
  • 2017-11-13 17:06:19
  • 435

Genymotion显示“genymotion virtualization engine not found”,

启动Genymotion,报错Unable to load virtualbox engine 【一、错误信息】 1、安装完後, 1)VirtualBox弹出“COM对象创建失败...
  • cpp597455873
  • cpp597455873
  • 2015-08-20 11:36:47
  • 1238

ArcGIS Engine不同格式数据打开,对象创建,导入导出

打开类public class clsOpenClass { public static void OpenFeatureClass(AxMapControl MapCon...
  • kone0611
  • kone0611
  • 2015-01-22 13:44:40
  • 1355
收藏助手
不良信息举报
您举报文章:engine
举报原因:
原因补充:

(最多只允许输入30个字)