Advertisement
DevilingMaster

Untitled

Jul 4th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.76 KB | None | 0 0
  1. URL url = new URL("http://www.montignac.com/it/ricerca-dell-indice-glicemico");
  2.         HttpURLConnection http = (HttpURLConnection) url.openConnection();
  3.        
  4.         Scanner scanner = new Scanner(http.getInputStream());
  5.         StringBuilder builder = new StringBuilder("");
  6.         while(scanner.hasNextLine())
  7.         {
  8.             builder.append(scanner.nextLine());
  9.             builder.append("\r\n");
  10.         }
  11.        
  12.         Pattern pattern = Pattern.compile("<div class=\"item-title-tab\">(.+)</div>\r\n<div class=\"item-ig-tab\">IG (\\d+?)</div>");
  13.         Matcher matcher = pattern.matcher(builder.toString());
  14.        
  15.         while(matcher.find())
  16.         {
  17.             System.out.println(matcher.group(1) + ";" + matcher.group(2));
  18.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement