Linux script help needed
===

I have been tasked to write a bash script that takes a  URL as its first argument and prints out statistics of the number of links per host/domain in the HTML of the URL.

So for instance given a URL like www.bbc.co.uk it might print something like

    www.bbc.co.uk: 45
    bbc.com: 1
    google.com: 2
    Facebook.com: 4

That is, it should analyse the HTML of the page, pull out all the links, examine the href attribute, decide which links are to the same domain (figure that one out of course), and which are foreign, then produce statistics for the local ones and for the remote ones.
I am a newbee to bash scripting and would really like some help on how i can achieve my task.
This is what i have been only able to do so far:

    #!/bin/bash
    echo "Enter url:"
    read url
    found= linkchecker $url |grep -i ^real