提取 Twitter 標記

    // Twitter markup documentation: 
    // https://dev.twitter.com/cards/markup
    String[] twitterTags = {
            "twitter:site", 
            "twitter:site:id", 
            "twitter:creator", 
            "twitter:creator:id", 
            "twitter:description", 
            "twitter:title", 
            "twitter:image", 
            "twitter:image:alt", 
            "twitter:player", 
            "twitter:player:width", 
            "twitter:player:height", 
            "twitter:player:stream", 
            "twitter:app:name:iphone", 
            "twitter:app:id:iphone", 
            "twitter:app:url:iphone", 
            "twitter:app:name:ipad", 
            "twitter:app:id:ipad", 
            "twitter:app:url:ipadt",
            "twitter:app:name:googleplay", 
            "twitter:app:id:googleplay", 
            "twitter:app:url:googleplay"        
    };
    
    // Connect to URL and extract source code
    Document doc = Jsoup.connect("http://stackoverflow.com/").get();
    
    for (String twitterTag : twitterTags) {
        
        // find a matching meta tag
        Element meta = doc.select("meta[name=" + twitterTag + "]").first();
        
        // if found, get the value of the content attribute
        String content = meta != null ? meta.attr("content") : "";
        
        // display results
        System.out.printf("%s = %s%n", twitterTag, content);
    }

輸出

twitter:site = 
twitter:site:id = 
twitter:creator = 
twitter:creator:id = 
twitter:description = Q&A for professional and enthusiast programmers
twitter:title = Stack Overflow
twitter:image = 
twitter:image:alt = 
twitter:player = 
twitter:player:width = 
twitter:player:height = 
twitter:player:stream = 
twitter:app:name:iphone = 
twitter:app:id:iphone = 
twitter:app:url:iphone = 
twitter:app:name:ipad = 
twitter:app:id:ipad = 
twitter:app:url:ipadt = 
twitter:app:name:googleplay = 
twitter:app:id:googleplay = 
twitter:app:url:googleplay =