// Chamando Robot public static void robot() throws Exception { Database db = new Database(); db.connect(); ResultSet rs = Page.findAll(db); Page p = null; while ((p = Page.next(rs)) != null) { String body = Robot.get(p.getUrl()); // procurar por urls dentro do body // buscar por essas paginas // String expr = "href=\"([^\"]*)"; String ereg = "href=\"https{0,1}:\\/\\/([^\"]*)\""; Pattern pt = Pattern.compile(ereg); Matcher m = pt.matcher(body); while (m.find()) { System.out.println(m.group()); String[] _url = m.group().split("\""); Page.newUrl(_url[1]); } p.setBody(body); p.update(); } db.close(); }
public static void newUrl(String url) throws Exception { String body = Robot.get(url); Page p = new Page(); p.setTmsp("2011-03-11 11:00:00"); p.setUrl(url); p.setBody(body); p.insert(); }
public void takeScreenshot(boolean flag) { BufferedImage bufferedimage; try { Robot robot = new Robot(); Point point = getLocationOnScreen(); Rectangle rectangle = new Rectangle(point.x, point.y, getWidth(), getHeight()); bufferedimage = robot.createScreenCapture(rectangle); } catch (Throwable throwable) { JOptionPane.showMessageDialog( frame, "An error occured while trying to create a screenshot!", "Screenshot Error", 0); return; } String s = null; try { s = getNearestScreenshotFilename(); } catch (IOException ioexception) { if (flag) { JOptionPane.showMessageDialog( frame, "A screenshot directory does not exist, and could not be created!", "No Screenshot Directory", 0); return; } } if (s == null && flag) { JOptionPane.showMessageDialog( frame, "There are too many screenshots in the screenshot directory!\n" + "Delete some screen\n" + "shots and try again.", "Screenshot Directory Full", 0); return; } if (!flag) { final JFileChooser fileChooser = new JFileChooser(); final JDialog fileDialog = createFileChooserDialog(fileChooser, "Save Screenshot", this); final BufferedImage si = bufferedimage; JFileChooser _tmp = fileChooser; fileChooser.setFileSelectionMode(0); fileChooser.addChoosableFileFilter(new imageFileFilter()); fileChooser.setCurrentDirectory(new File("C:/.hack3rClient/Scre/")); fileChooser.setSelectedFile(new File(s)); JFileChooser _tmp1 = fileChooser; fileChooser.setDialogType(1); fileChooser.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionevent) { String s1 = actionevent.getActionCommand(); if (s1.equals("ApproveSelection")) { File file = fileChooser.getSelectedFile(); if (file != null && file.isFile()) { int i = JOptionPane.showConfirmDialog( frame, (new StringBuilder()) .append(file.getAbsolutePath()) .append(" already exists.\n" + "Do you want to replace it?") .toString(), "Save Screenshot", 2); if (i != 0) { return; } } try { ImageIO.write(si, "png", file); // client.pushMessage("Screenshot taken.", 3, "@cr2@ Client"); // JOptionPane.showMessageDialog(frame,"Screenshot Taken"); } catch (IOException ioexception2) { JOptionPane.showMessageDialog( frame, "An error occured while trying to save the screenshot!\n" + "Please make sure you have\n" + " write access to the screenshot directory.", "Screenshot Error", 0); } fileDialog.dispose(); } else if (s1.equals("CancelSelection")) { fileDialog.dispose(); } } { } }); fileDialog.setVisible(true); } else { try { ImageIO.write( bufferedimage, "png", new File((new StringBuilder()).append("C:/.hack3rClient/Scre/").append(s).toString())); JOptionPane.showMessageDialog( frame, "Image has been saved to C:/.hack3rclient/Scre. You can view your images by pushing File>View Images in the menu dropdowns.", "Screenshot manager", JOptionPane.INFORMATION_MESSAGE); // client.pushMessage("Screenshot taken.", 3, "@cr2@ Client"); // JOptionPane.showMessageDialog(frame,"Screenshot taken."); } catch (IOException ioexception1) { JOptionPane.showMessageDialog( frame, "An error occured while trying to save the screenshot!\n" + "Please make sure you have\n" + " write access to the screenshot directory.", "Screenshot Error", 0); } } }