Get relevant image and summary from URL
===

I'm not sure how to define it but basically I want to retrieve a relevant image and text summary from a given URL.

For example - when a user pastes a link to the share box on Facebook, it immediately gets the article title and/or a short text block from the article itself and a relevant image.
It never gets the wrong image, like the logo of the site or text from around the article itself...

Same for Google+ and other social networks or services like these.

I started by assuming I need to read the page content using the below code, how can I determine which image is the relevant one (from the article body) and which text is the article text?
 

    URL oracle = new URL("http://www.oracle.com/");
            BufferedReader in = new BufferedReader(
            new InputStreamReader(oracle.openStream()));
    
            String inputLine;
            while ((inputLine = in.readLine()) != null)
                System.out.println(inputLine);
            in.close();

I'm of course not asking for code here (unless someone has a snippet for example and is willing to share) but more for how to even approach this... where do I start?

Any help will be appreciated!