# the following code is adjusted for Python 3.x 

import collections
import re
import urllib.request

url = 'https://courseworks.columbia.edu/access/content/group/COMSW3101_002_2015_3/week3/hamlet.html'

speech = []
linecnt = 0

with urllib.request.urlopen(url) as ef:
    for bin in ef:
        linecnt += 1
        s = bin.decode('utf-8')
        names = re.findall(r'<b>(.+)</b>',s)
        if len(names) !=0:
            speech.extend(names)

count = collections.defaultdict(int)
for name in speech:
    count[name] += 1

print ([linecnt, len(speech),count])


    
