解决爬虫中文数据乱码问题
爬虫时想通过request请求获取文本内容
开始使用
requests.get.text获取字符串发现中文存在乱码现象
tr class=“odd”>11战狼2</a
尝试使用requests.get.text.decode(‘utf-8’)进行解码,显示字符串不能解码
AttributeError: ‘str’ object has no attribute ‘decode’
解决方法
使用requests.get.content得到正确字符串
爬虫时想通过request请求获取文本内容
开始使用
requests.get.text获取字符串发现中文存在乱码现象
tr class=“odd”>11战狼2</a
尝试使用requests.get.text.decode(‘utf-8’)进行解码,显示字符串不能解码
AttributeError: ‘str’ object has no attribute ‘decode’
解决方法
使用requests.get.content得到正确字符串