小编Jtw*_*twa的帖子

Python web-scraping错误 - TypeError:不能在类字节对象上使用字符串模式

我想建立一个网络刮板.目前,我正在学习Python.这是非常基础!

Python代码

import urllib.request
import re

htmlfile = urllib.request.urlopen("http://basketball.realgm.com/")

htmltext = htmlfile.read()
title = re.findall('<title>(.*)</title>', htmltext)

print (htmltext)
Run Code Online (Sandbox Code Playgroud)

错误:

  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
Run Code Online (Sandbox Code Playgroud)

findall scraper web-scraping python-3.x

4
推荐指数
1
解决办法
2826
查看次数

标签 统计

findall ×1

python-3.x ×1

scraper ×1

web-scraping ×1