TypeError: 'encording' is an invalid keyword argument for this function

来源:13-7 正则分析HTML

excvavtor

2018-06-26

from urllib import request      

import re



class Spider():

    url = 'https://www.panda.tv/'

    # 使用组取两个定位标签中间的内容

    root_pattern = '<div class="video-info">([\s\S]*?)</div>'    


    def __fetch_content(self):          

        r = request.urlopen(Spider.url)     

        htmls = r.read()                    

        htmls = str(htmls, encording='utf-8')     # 这句报错了 我的python版本是3.6

        return htmls


    def __analysis(self, htmls):

        root_html = re.findall(Spider.root_pattern, htmls)


    def go(self):           

        htmls = self.__fetch_content()

        self.__analysis(htmls)



spider = Spider()

spider.go()


写回答

1回答

excvavtor

提问者

2018-06-26

encoding 关键字错了。。

0
0

Python3.8系统入门+进阶 (程序员必备第二语言)

语法精讲/配套练习+思考题/原生爬虫实战

14640 学习 · 4477 问题

查看课程