您的位置:首页 > 编程语言 > Python开发

PYTHON 爬虫错误总结

2018-03-21 16:22 169 查看
一、urlopen()、urlretrieve()、urlencode()报错:主要是python3和python2版本不同造成的

其中'urlopen', 'urlparse','urlretrieve','urlsplit','urlunparse',属于request子模块,
'urlencode', 'urljoin','urlparse','urlsplit','urlunparse','urlunsplit',属于parse子模块。两个模块中有相同的函数。1、import urllib.request
2、s = urllib.request.urlopen(url)二、'HTTPMessage' object has no attribute 'getheader'1、使用get()接口
2、s = urllib.request.urlopen(url)
msg = s.info() #get a message object
print(msg.get("Content-Type"))三、对于解析不再使用urlparse_qs()而是parse_qs()
四、html解析器在html.parser模块中HTMLParser
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: