TypeError: no se puede usar un patrón de cadena en un objeto similar a bytes en re.findall ()
Estoy tratando de aprender cómo recuperar automáticamente las URL de una página. En el siguiente código intento obtener el título de la página web:
import urllib.request
import re
url = "http://www.google.com"
regex = '<title>(,+?)</title>'
pattern = re.compile(regex)
with urllib.request.urlopen(url) as response:
html = response.read()
title = re.findall(pattern, html)
print(title)
Y me sale este error inesperado:
Traceback (most recent call last):
File "path\to\file\Crawler.py", line 11, in <module>
title = re.findall(pattern, html)
File "C:\Python33\lib\re.py", line 201, in findall
return _compile(pattern, flags).findall(string)
TypeError: can't use a string pattern on a bytes-like object
¿Qué estoy haciendo mal?