That worked for me in python3. Hope this helps
import urllib.request
import re
urls = ["https://google.com","https://nytimes.com","http://CNN.com"]
i = 0
regex = '<title>(.+?)</title>'
pattern = re.compile(regex)
while i < len(urls) :
htmlfile = urllib.request.urlopen(urls[i])
htmltext = htmlfile.read()
titles = re.search(pattern, str(htmltext))
print(titles)
i+=1
And also this in which i added b before regex to convert it into byte array.
import urllib.request
import re
urls = ["https://google.com","https://nytimes.com","http://CNN.com"]
i = 0
regex = b'<title>(.+?)</title>'
pattern = re.compile(regex)
while i < len(urls) :
htmlfile = urllib.request.urlopen(urls[i])
htmltext = htmlfile.read()
titles = re.search(pattern, htmltext)
print(titles)
i+=1