Ejemplo n.º 1
0
  private void runAll(String arg1, int arg2, int arg3, int arg4, String fname)
      throws MalformedURLException, Exception {
    System.out.println("\nObteniendo lista de archivos html ------------------------");
    System.out.print("Obteniendo-> " + arg1 + " ... ");
    WebFile file = new WebFile(arg1);
    Object content = file.getContent();
    System.out.println("DONE!");
    if (content instanceof String) {
      String html = (String) content;
      html =
          html.substring(
              html.indexOf("<td class=\"sectiontableheader\" align=\"right\" width=\"5%\">"),
              html.indexOf("<td align=\"center\" colspan=\"4\" class=\"sectiontablefooter\">"));
      System.out.println("\nObteniendo URLs Base ------------------------");
      html = getBaseURLs(arg1, html);
      if (arg2 != 0 && arg3 != 0) {
        for (int i = arg2; i <= arg3; i++) {
          System.out.print(arg1 + "Pagina-" + i + "-" + arg4 + ".html ... ");
          file = new WebFile(arg1 + "Pagina-" + i + "-" + arg4 + ".html");
          content = file.getContent();
          System.out.println("DONE!");
          String html2 = (String) content;
          html2 =
              html2.substring(
                  html2.indexOf("<td class=\"sectiontableheader\" align=\"right\" width=\"5%\">"),
                  html2.indexOf(
                      "<td align=\"center\" colspan=\"4\" class=\"sectiontablefooter\">"));
          html = html + getBaseURLs(arg1, html2);
        }
      }
      html = getKMLURLS(html.split("\n"));

      System.out.print("Guardando-> " + fname + " ... ");
      FileWriter fstream = new FileWriter(fname);
      BufferedWriter out = new BufferedWriter(fstream);
      out.write(html);
      out.close();
      System.out.print("Done!");

      getKMLs(html.split("\n"));
    }
  }
Ejemplo n.º 2
0
  private String getKMLURLS(String[] urls) throws MalformedURLException, Exception {
    System.out.println("\nObteniendo URLS de KML ------------------------");
    int n = urls.length;
    StringBuilder sb = new StringBuilder("");
    for (int i = 0; i < n; i++) {
      WebFile file;
      if (urls[i].equals("") || urls[i].isEmpty()) {

      } else {
        file = new WebFile("http://www.rutasjalisco.gob.mx" + urls[i]);
        Object content = file.getContent();
        if (content instanceof String) {
          String html = (String) content;
          sb.append(getKMLURL(html));
          sb.append("\n");
        }
      }
    }
    return sb.toString();
  }