Ejemplo n.º 1
0
  @Override
  public void parseComicURL() { // parse URL and save all URLs in comicURL  //
    // 先取得前面的下載伺服器網址

    String allPageString = Common.getFileString(SetUp.getTempDirectory(), indexName);
    Common.debugPrint("開始解析這一集有幾頁 : ");

    int beginIndex = 0, endIndex = 0;

    totalPage = allPageString.split("<option ").length;
    Common.debugPrintln("共 " + totalPage + " 頁");
    comicURL = new String[totalPage];

    String picURL = "";
    int p = 0; // 目前頁數
    for (int i = 0; i < totalPage && Run.isAlive; i++) {
      beginIndex = allPageString.indexOf("<img id");
      beginIndex = allPageString.indexOf("\"", beginIndex) + 1;
      endIndex = allPageString.indexOf("\"", beginIndex);
      String tempURL = allPageString.substring(beginIndex, endIndex);

      if (Common.isLegalURL(tempURL)) {
        comicURL[p++] = tempURL;
        Common.debugPrintln(p + " " + comicURL[p - 1]); // debug
        // 每解析一個網址就下載一張圖
        singlePageDownload(getTitle(), getWholeTitle(), comicURL[p - 1], totalPage, p, 0);
      } else {
        totalPage--;
      }
      // Common.downloadFile( comicURL[p - 1], "", p + ".jpg", false, "" );

      if (p < totalPage) {
        beginIndex = allPageString.indexOf("</select>");
        beginIndex = allPageString.indexOf("\"", beginIndex) + 1;
        endIndex = allPageString.indexOf("\"", beginIndex);
        tempURL = allPageString.substring(beginIndex, endIndex);
        if ("#".equals(tempURL)) {
          Common.debugPrintln("THE LAST PAGE !!");
          break;
        }

        String nextPageURL = "http://comic101.com" + tempURL;

        Common.downloadFile(nextPageURL, SetUp.getTempDirectory(), indexName, false, "");
        allPageString = Common.getFileString(SetUp.getTempDirectory(), indexName);
      }
    }

    // System.exit( 0 ); // debug
  }
Ejemplo n.º 2
0
  @Override
  public void parseComicURL() { // parse URL and save all URLs in comicURL  //
    // 先取得前面的下載伺服器網址

    String allPageString = Common.getFileString(SetUp.getTempDirectory(), indexName);
    Common.debugPrint("開始解析這一集有幾頁 : ");

    int beginIndex = allPageString.indexOf("name=\"selectb\"");
    beginIndex = allPageString.indexOf(">", beginIndex) + 1;
    int endIndex = allPageString.indexOf("</select>", beginIndex);

    String tempString = allPageString.substring(beginIndex, endIndex);

    totalPage = tempString.split("<option").length - 1;
    Common.debugPrintln("共 " + totalPage + " 頁");
    comicURL = new String[totalPage];

    String[] comicPageURL = new String[totalPage];
    beginIndex = endIndex = 0;
    for (int i = 0; i < totalPage && Run.isAlive; i++) {
      beginIndex = allPageString.indexOf("value=", beginIndex);
      beginIndex = allPageString.indexOf("\"", beginIndex) + 1;
      endIndex = allPageString.indexOf("\"", beginIndex);

      comicPageURL[i] = baseURL + allPageString.substring(beginIndex, endIndex);
    }

    String picURL = "";
    for (int p = 0; p < totalPage; p++) {
      if (!Common.existPicFile(getDownloadDirectory(), p + 1)
          || !Common.existPicFile(getDownloadDirectory(), p + 2)) {
        allPageString = getAllPageString(comicPageURL[p]);

        beginIndex = allPageString.indexOf("id=picwin");
        beginIndex = allPageString.indexOf("src=", beginIndex);
        beginIndex = allPageString.indexOf("\"", beginIndex) + 1;
        endIndex = allPageString.indexOf("\"", beginIndex);

        comicURL[p] = Common.getFixedChineseURL(allPageString.substring(beginIndex, endIndex));
        // Common.debugPrintln( ( p + 1 ) + " " + comicURL[p] ); // debug

        // 每解析一個網址就下載一張圖
        singlePageDownload(getTitle(), getWholeTitle(), comicURL[p], totalPage, p + 1, 0);
      }
    }

    // System.exit( 0 ); // debug
  }
Ejemplo n.º 3
0
  @Override
  public void parseComicURL() { // parse URL and save all URLs in comicURL  //
    // 先取得前面的下載伺服器網址

    String allPageString = getAllPageString(webSite);
    Common.debugPrint("開始解析這一集有幾頁 : ");

    String baseURL = "http://mh2.xindm.cn";

    int beginIndex = allPageString.indexOf("Array(");
    beginIndex = allPageString.indexOf("\"", beginIndex);
    int endIndex = allPageString.indexOf(");", beginIndex);
    String tempPicString = allPageString.substring(beginIndex, endIndex);
    String[] picURLs = tempPicString.split(",");

    totalPage = picURLs.length;
    Common.debugPrintln("共 " + totalPage + " 頁");
    comicURL = new String[totalPage];

    for (int i = 0; i < picURLs.length; i++) {
      comicURL[i] = baseURL + picURLs[i].replaceAll("\"", "");
      Common.debugPrintln("第" + (i + 1) + "頁網址:" + comicURL[i]);
    }

    // 須取得cookie才能下載圖片(防盜連專家....)
    String[] cookies = Common.getCookieStrings(webSite, null);
    String cookieString = "";
    int cookieCount = 0; // 取得前兩組cookie就可以了
    if (cookies[0] != null) {

      cookieString =
          "Hm_lvt_016bf6f495d44a067f569423ad894560=1337210178886; " + cookies[0].split(";")[0];
    }
    Common.debugPrintln("取得cookies:" + cookieString);

    for (int p = 1; p <= totalPage && Run.isAlive; p++) {

      String referURL = webSite + "?p=" + p;
      // 每解析一個網址就下載一張圖
      singlePageDownloadUsingSimple(
          getTitle(), getWholeTitle(), comicURL[p - 1], totalPage, p, cookieString, referURL);

      Common.debugPrintln((p) + " " + comicURL[p - 1] + " " + referURL); // debug
    }
    // System.exit(1); // debug
  }
Ejemplo n.º 4
0
  @Override
  public void parseComicURL() { // parse URL and save all URLs in comicURL  //
    // 先取得前面的下載伺服器網址

    initNewData();

    String allPageString = Common.getFileString(SetUp.getTempDirectory(), indexName);
    Common.debugPrint("開始解析這一集有幾頁 : ");

    if (tsukkomiMode) {
      int beginIndex = 0;
      int endIndex = 0;
      String listURL = webSite;
      List<String> tagNameList = new ArrayList<String>();

      if (webSite.matches(".*/")) {
        listURL = webSite.substring(0, webSite.length() - 1);
      }

      if (isRssPage()) {
        print("is RSS page : " + listURL);
        outputNewListFile(listURL);
        tagNameList = getTagNameList(listURL);

        for (int i = 0; i < tagNameList.size(); i++) // 作品列表
        {
          String tagName = tagNameList.get(i);
          handleSingleTitle(tagName);
        }
      } else // ex.
      // http://manhua.dmzj.com/tags/category_search/0-0-0-all-0-0-1-447.shtml#category_nav_anchor
      {
        print("is Normal List Page : " + webSite);

        if (webSite.indexOf("/update_") > 0) {
          handleAllUpdatePage();
        } else if (webSite.indexOf("/rank/") > 0) {
          handleAllRankPage();
        }
      }

      System.exit(0);
    }

    // 取得所有位址編碼代號
    int beginIndex = allPageString.indexOf("'[") + 2;
    int endIndex = allPageString.indexOf("\"]", beginIndex) + 1;

    String allCodeString = allPageString.substring(beginIndex, endIndex);

    totalPage = allCodeString.split("\",\"").length;
    Common.debugPrintln("共 " + totalPage + " 頁");
    comicURL = new String[totalPage];
    refers = new String[totalPage];

    // 取得位址編碼代號的替換字元
    beginIndex = allPageString.indexOf(",'", endIndex) + 2;
    endIndex = allPageString.indexOf("'.", beginIndex);
    String allVarString = allPageString.substring(beginIndex, endIndex);

    String[] varTokens = allVarString.split("\\|");

    for (int i = 0; i < varTokens.length; i++) {
      Common.debugPrintln(i + " " + varTokens[i]); // test
    }
    // System.exit( 0 );

    String basePicURL = "http://images.dmzj.com/"; // "http://images.manhua.178.com/";
    String[] codeTokens = allCodeString.split("\",\"");

    codeTokens = getRealCodeTokens(codeTokens, varTokens);

    String firstCode = codeTokens[0].replaceAll("\"", "");

    String firstPicURL = "";
    Common.debugPrintln("第一張編碼:" + firstCode);
    firstPicURL = basePicURL + Common.getFixedChineseURL(getDecodeURL(firstCode));
    firstPicURL = firstPicURL.replaceAll("\\\\", "");

    Common.debugPrintln("第一張圖片網址:" + firstPicURL);

    // System.exit( 0 );

    String[] picNames = new String[totalPage];
    for (int i = 0; i < picNames.length; i++) {
      codeTokens[i] = codeTokens[i].replaceAll("\"", "");
      beginIndex = codeTokens[i].lastIndexOf("/") + 1;
      endIndex = codeTokens[i].length(); // .lastIndexOf( "\"" );
      // Common.debugPrintln( codeTokens[i] + " " + beginIndex + " " + endIndex );
      picNames[i] =
          Common.getFixedChineseURL(getDecodeURL(codeTokens[i].substring(beginIndex, endIndex)));

      // System.exit( 0 ); // debug
    }

    endIndex = firstPicURL.lastIndexOf("/") + 1;
    String parentPicURL = firstPicURL.substring(0, endIndex);

    for (int i = 0; i < codeTokens.length && Run.isAlive; i++) {
      comicURL[i] = parentPicURL + picNames[i]; // 存入每一頁的網頁網址
      refers[i] = webSite;
      // Common.debugPrintln( ( i + 1 ) + " " + comicURL[i]  ); // debug

    }

    // System.exit( 0 ); // debug
  }