Post页面爬取失败__编码问题

python3爬取Post页面时, 报以下错误

 

"POST data should be bytes or an iterable of bytes. It cannot be of type str."

解决方案:

需要在urlencode语句后加encode(encoding='UTF8')

data = urllib.parse.urlencode(values).encode(encoding='UTF8')

  

 

posted @ 2018-06-04 17:21  阿谋  阅读(184)  评论(0编辑  收藏  举报