import urllib.request
import re
f = urllib.request.urlopen('http://www.geekynu.cn/')
html = f.read()
title = re.search('<title>(.*?)</title>', html)
print(title)
#print(title.decode('utf-8')) //I had try to solve by this code.
Run Code Online (Sandbox Code Playgroud)
[python 3.5] 当我使用re.search()阅读网页标题时,出现错误“TypeError: cannot use a string pattern on a bytes-like object”,我该怎么办?谢谢!
| 归档时间: |
|
| 查看次数: |
14578 次 |
| 最近记录: |