<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    URL分別用三個List保存,
    一個是boring,這個list中的url最后來下載
    其他兩個是interesting和average
    當搜索到url時檢查是否包含設定為boring的詞,并放入boring中

    用戶可設定“深度搜索”:每搜到一個url就放在list的最前面
    也可廣度

    有些網頁鏈接要特殊處理:

    url = textReplace("?", URLEncoder.encode("?"), url);
    url = textReplace("&", URLEncoder.encode("&"), url);
    private String textReplace(String find, String replace, String input)
    {
        int startPos = 0;
         while(true)
        {
            int textPos = input.indexOf(find, startPos);
            if(textPos < 0)
            {
                break;
            }
            input = input.substring(0, textPos) + replace + input.substring(textPos + find.length());
            startPos = textPos + replace.length();
        }
        return input;
    }

    讀取資源代碼:

    BufferedInputStream remoteBIS = new BufferedInputStream(conn.getInputStream());
    ByteArrayOutputStream baos = new ByteArrayOutputStream(10240);
    byte[] buf = new byte[1024];
    int bytesRead = 0;
    while(bytesRead >= 0)
    {
        baos.write(buf, 0, bytesRead);
        bytesRead = remoteBIS.read(buf);
    }

    byte[] content = baos.toByteArray();


    建立多級目錄:

    File f = new File(fileName);
    f.getParentFile().mkdirs();
    FileOutputStream out = new FileOutputStream(fileName);
    out.write(content);
    out.flush();
    out.close();


    給一個變量寫doc:(在eclipse中,鼠標置上會顯示)

    /**
    * Set of URLs downloaded or scheduled, so we don't download a
    * URL more than once.
    * Thread safety: To access the set, first synchronize on it.
    */
    private Set urlsDownloadedOrScheduled;


    這種log挺好:(apache log4j)

    private final static Category _logClass = Category.getInstance(TextSpider.class);

    /*
    顯示信息: 2005-05-01 11:40:44,250 [main] INFO? TextSpider.java:105 - Starting Spider...
    */
    _logClass.info("Starting Spider...");



    版權所有 羅明
    posted on 2006-02-16 14:10 羅明 閱讀(620) 評論(0)  編輯  收藏 所屬分類: Java
     
    主站蜘蛛池模板: 亚洲日韩国产二区无码| 有码人妻在线免费看片| 日韩免费电影在线观看| 污污视频网站免费观看| 亚洲日韩精品A∨片无码| 国产成人无码免费看视频软件| 在线观看片免费人成视频无码| 情人伊人久久综合亚洲| 毛片免费视频在线观看| 一个人免费观看日本www视频| 日韩亚洲Av人人夜夜澡人人爽| 日韩中文字幕在线免费观看| 免费人成毛片动漫在线播放| 亚洲中久无码不卡永久在线观看| 久久99热精品免费观看牛牛| 337P日本欧洲亚洲大胆精品| 亚洲AV无码精品无码麻豆| 丝袜足液精子免费视频| 亚洲一区二区三区在线| 中文字幕精品无码亚洲字| 亚洲欧洲免费无码| 国产情侣久久久久aⅴ免费| 亚洲精品伦理熟女国产一区二区| 亚洲AV中文无码乱人伦下载| 欧洲精品免费一区二区三区| 99ee6热久久免费精品6| 男女超爽视频免费播放| 亚洲小说图片视频| 亚洲精品无码国产| 国产一区二区三区免费视频| 18禁免费无码无遮挡不卡网站 | 免费久久精品国产片香蕉| 久久99青青精品免费观看| 猫咪免费人成网站在线观看入口 | 久久久WWW免费人成精品| 亚洲va久久久久| 五月天网站亚洲小说| 久久久久亚洲精品无码网址 | 午夜视频免费观看| 国产亚洲精品免费| 亚洲精品福利你懂|