码迷,mamicode.com
首页 > 编程语言 > 详细

python爬虫中遇到的问题以及解决方法

时间:2019-12-22 20:06:47      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:解决方案   bin   span   pen   string   解决   not   image   匹配   

1)运行后报错:“TypeError: cannot use a string pattern on a bytes-like”

原因:content用decode(‘utf-8’)进行解码,由bytes变成string。py3的urlopen返回的不是string是bytes。

解决方案:把’content’类型调整一下:content.decode(‘utf-8’)

技术图片

 

 

2)运行后报错:“sqlite3.InterfaceError: Error binding parameter 1 - probably unsupported type”

原因:数据取出来是列表型的,和数据库设计的字段不匹配,需要将数据处理为字符串类型。

 

解决方案:遍历列表,将列表中的所有元素拼接为一个字符串

 

技术图片

 

python爬虫中遇到的问题以及解决方法

标签:解决方案   bin   span   pen   string   解决   not   image   匹配   

原文地址:https://www.cnblogs.com/hyz1900457346/p/12080603.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!