コード例 #1
0
ファイル: SourceStat.java プロジェクト: dalinhuang/xdarkness
  public static String[] getSearchEngine(Visit v) {
    String url = v.URL;
    if (StringUtil.isEmpty(url)) {
      return null;
    }

    if (url.indexOf("Result.jsp") > 0) {
      String keyword = SearchAPI.getParameter(url, "query");
      return new String[] {"站内搜索", keyword};
    }
    url = v.Referer;
    String domain = StatUtil.getDomain(url);
    Mapx map = ServletUtil.getMapFromQueryString(url);
    String name = null;
    String keyword = null;
    if (domain.indexOf("baidu.") > 0) {
      keyword = StringUtil.urlDecode(map.getString("wd"), "GBK");
      name = "百度";
    } else if (domain.indexOf("google.") > 0) {
      String charset = map.getString("ie");
      if (StringUtil.isEmpty(charset)) {
        charset = "UTF-8";
      }
      keyword = StringUtil.urlDecode(map.getString("q"), charset);
      name = "谷歌";
    } else if (domain.indexOf("yahoo.") > 0) {
      String charset = map.getString("ei");
      if (StringUtil.isEmpty(charset)) {
        charset = "UTF-8";
      }
      keyword = StringUtil.urlDecode(map.getString("p"), charset);
      name = "雅虎";
    } else if (domain.indexOf("msn.") > 0) {
      keyword = StringUtil.urlDecode(map.getString("q"), "UTF-8");
      name = "MSN";
    } else if (domain.indexOf("soso.") > 0) {
      keyword = StringUtil.urlDecode(map.getString("w"), "GBK");
      name = "搜搜";
    } else if (domain.indexOf("sogou.") > 0) {
      keyword = StringUtil.urlDecode(map.getString("query"), "GBK");
      name = "搜狗";
    } else if (domain.indexOf("zhongsou.") > 0) {
      keyword = StringUtil.urlDecode(map.getString("word"), "GBK");
      name = "中搜";
    } else if (domain.indexOf("youdao.") > 0) {
      String charset = map.getString("ue");
      if (StringUtil.isEmpty(charset)) {
        charset = "UTF-8";
      }
      keyword = StringUtil.urlDecode(map.getString("q"), charset);
      name = "有道";
    } else if (domain.indexOf("live.") > 0) {
      keyword = StringUtil.urlDecode(map.getString("q"), "UTF-8");
      name = "Live.com";
    }
    if (StringUtil.isNotEmpty(keyword)) {
      return new String[] {name, keyword};
    }
    return null;
  }
コード例 #2
0
ファイル: SourceStat.java プロジェクト: dalinhuang/xdarkness
 public void deal(Visit v) {
   if ("Unload".equals(v.Event)) {
     return;
   }
   if (!this.siteMap.containsKey(new Long(v.SiteID))) {
     VisitCount.getInstance().initLRUMap(v.SiteID, "Source", "Keyword", 1000, null);
     VisitCount.getInstance().initLRUMap(v.SiteID, "Source", "Referer", 1000, null);
     this.siteMap.put(new Long(v.SiteID), "");
   }
   VisitCount.getInstance().add(v.SiteID, "Source", "Host", v.Host);
   if (v.UVFlag)
     if ((StringUtil.isEmpty(v.Referer)) && (v.URL.indexOf("Result.jsp") < 0)) {
       VisitCount.getInstance().add(v.SiteID, "Source", "Direct", "0");
     } else {
       String[] se = getSearchEngine(v);
       if (se == null) {
         String domain = StatUtil.getDomain(v.Referer);
         if (!domain.equalsIgnoreCase(v.Host))
           VisitCount.getInstance().add(v.SiteID, "Source", "Referer", domain);
         else VisitCount.getInstance().add(v.SiteID, "Source", "Direct", "0");
       } else {
         VisitCount.getInstance().add(v.SiteID, "Source", "SearchEngine", se[0]);
         VisitCount.getInstance().add(v.SiteID, "Source", "Keyword", se[1]);
       }
     }
 }