首页 > Web开发 > 详细

html decode

时间:2020-03-25 17:54:06      阅读:59      评论:0      收藏:0      [点我收藏+]

error:

 /usr/bin/python3 /home/cor/webscrappython/Web_Scraping_with_Python/chapter01/link_crawler2.py
Downloading:http://example.webscraping.com
Downloading --- 5
Traceback (most recent call last):
  File "/home/cor/webscrappython/Web_Scraping_with_Python/chapter01/link_crawler2.py", line 38, in <module>
    link_crawler(‘http://example.webscraping.com‘, ‘/(index|view)‘)
  File "/home/cor/webscrappython/Web_Scraping_with_Python/chapter01/link_crawler2.py", line 16, in link_crawler
    for link in get_links(html):
  File "/home/cor/webscrappython/Web_Scraping_with_Python/chapter01/link_crawler2.py", line 34, in get_links
    return webpage_regex.findall(html)
TypeError: cannot use a string pattern on a bytes-like object

  solution:

 

you want to convert html (a byte-like object) into a string using .decode,
e.g. html = response.read().decode(‘utf-8‘)

  

 

html decode

原文:https://www.cnblogs.com/winditsway/p/12567416.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!