我想使用函数 re.findall(),它在网页中搜索特定模式:
from urllib.request import Request, urlopen
import re
url = Request('http://www.cmegroup.com/trading/products/#sortField=oi&sortAsc=false&venues=3&page=1&cleared=1&group=1', headers={'User-Agent': 'Mozilla/20.0.1'})
webpage = urlopen(url).read()
findrows = re.compile('<td class="cmeTableCenter">(.*)</td>')
row_array = re.findall(findrows, webpage) #ERROR HERE
我收到一个错误:
TypeError: can't use a string pattern on a bytes-like object