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

根据所抓取的网页来修改编码, 如果网页编码是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)

posted @ 2017-10-08 21:27  深圳地铁Princess  阅读(528)  评论(0编辑  收藏  举报