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")); } }
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(); }
private void fetchOne(boolean examine, boolean save, YouAreEll yrl, InputStream is) { logger.entering(examine); logger.entering(save); logger.entering(yrl); if (examine) is = new DelimitedBufferedInputStream(is, '<', '>'); BufferedOutputStream bos = null; WebFile wf = null; if (save) { wf = new WebFile(yrl, args); bos = wf.getBOS(); if (bos == null) save = false; } if (save || examine) { if (!examineORsave(yrl, is, bos, examine, save, yrl.getURL())) { logger.severe("examineORsave failed"); } } if (bos != null) { try { bos.close(); if (args.SetLastModified) wf.getFile().setLastModified(yrl.getLastModified()); } catch (IOException e) { logger.throwing(e); } } if (examine) { try { is.close(); } catch (IOException e) { logger.throwing(e); } } }