python3写爬虫报错--------TypeError: cannot use a string pattern on a bytes-like object

时间:2021-01-22 20:15:26

根据所抓取的网页来修改编码, 如果网页编码是utf-8, 那就html=html.decode('utf-8')

上下文是这样的

html = ''
    while True:
        html = loadurl(url)

        if html == '':
            print ('load', url,'error')
            print ('oppa')
            continue
        else:
            break
    seriesList = re.findall(reSeriesList,html.decode('GBK'),re.S)