Guest User

asdfg

a guest
Dec 7th, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. package demmonic.hf;
  2.  
  3. import java.io.IOException;
  4.  
  5. import org.jsoup.Connection;
  6. import org.jsoup.Jsoup;
  7. import org.jsoup.nodes.Document;
  8. import org.jsoup.nodes.Element;
  9. import org.jsoup.select.Elements;
  10.  
  11. /**
  12.  *
  13.  * @author Demmonic
  14.  *
  15.  */
  16. public final class Entry {
  17.  
  18.     private Entry() { }
  19.  
  20.     public static void main(String[] args) throws IOException {
  21.         String link = "http://www.bloomberg.com/quote/UKX:IND/members";
  22.         Connection con = Jsoup.connect(link);
  23.         Document doc = con.get();
  24.        
  25.         Elements entries = doc.select(".odd");
  26.         for (Element e : entries) {
  27.             Elements nameChildren = e.select("[class=first name]");
  28.             Element nameChild = nameChildren.first();
  29.             if (nameChild == null) continue;
  30.            
  31.             // there's actually 2 children with the value class, but we only want the first one
  32.             Elements valueChildren = e.select(".value");
  33.             Element valueChild = valueChildren.first();
  34.             if (valueChild == null) continue;
  35.            
  36.             String name = nameChild.text();
  37.             String value = valueChild.text();
  38.            
  39.             System.out.println(name + " -> " + value);
  40.         }
  41.     }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment