Exemplo n.º 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();
 }
Exemplo n.º 2
0
 public static String pageParse(String url) {
   // &sort_type=sort_pubdate_desc&page_index=2
   String path = "";
   if (url.startsWith(DangConstants.DANG_BOOK_PREFIX)) {
     path =
         url.substring(
             DangConstants.DANG_BOOK_PREFIX.length(),
             DangConstants.DANG_BOOK_PREFIX.length() + 17);
   }
   if (path.endsWith("00.00")) {
     return DangConstants.DANG_BOOK_PREFIX + path + "&sort_type=sort_pubdate_desc&page_index=";
   }
   return path;
 }
Exemplo n.º 3
0
 public static String url2Dir(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("/");
     }
   }
   return DangConstants.DANG_ROOT_DIR + "/" + sb.toString();
 }
Exemplo n.º 4
0
 public static String url2Path(String url, Map<String, String> map) {
   String path = "01.00.00.00.00.00";
   StringBuilder sbm = new StringBuilder();
   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("-");
       sbm.append(map.get(sb.toString()) + ">");
     }
   }
   return sbm.toString();
 }
Exemplo n.º 5
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();
 }