Beispiel #1
0
 public static String getFilename(String url) {
   if (url.startsWith("http://product.dangdang.com/")) {
     return getProductId(url) + ".html";
   }
   String path = "01.00.00.00.00.00";
   StringBuilder sb = new StringBuilder();
   if (url.startsWith(DangConstants.DANG_BOOK_PREFIX)) {
     path =
         url.substring(
             DangConstants.DANG_BOOK_PREFIX.length(),
             DangConstants.DANG_BOOK_PREFIX.length() + 17);
   }
   String[] s = path.split("\\.");
   for (String o : s) {
     if (!o.equals("00")) {
       sb.append(o);
       sb.append("-");
     }
   }
   if (url.contains(DangConstants.PAGE_INDEX)) {
     sb.append(
         url.substring(url.indexOf(DangConstants.PAGE_INDEX) + DangConstants.PAGE_INDEX.length()));
   }
   sb.append(".html");
   return sb.toString();
 }
Beispiel #2
0
 public static String getDirPath(String url) {
   String path = "01.00.00.00.00.00";
   StringBuilder sb = new StringBuilder();
   if (url.startsWith(DangConstants.DANG_BOOK_PREFIX)) {
     path =
         url.substring(
             DangConstants.DANG_BOOK_PREFIX.length(),
             DangConstants.DANG_BOOK_PREFIX.length() + 17);
   }
   String[] s = path.split("\\.");
   for (String o : s) {
     if (!o.equals("00")) {
       sb.append(o);
       sb.append("-");
     }
   }
   if (url.contains(DangConstants.PAGE_INDEX)) {
     sb.append(
         url.substring(url.indexOf(DangConstants.PAGE_INDEX) + DangConstants.PAGE_INDEX.length()));
   }
   return sb.toString();
 }