zoukankan      html  css  js  c++  java
  • html decode

    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')

      

  • 相关阅读:
    GUI起头
    最大公约数
    最小公倍数
    最大公约数、最小公倍数
    质数——筛选法
    质数——用已有质数求质数
    质数——6N±1法
    质数——1到n遍历法
    微服务的优势
    收到offer!
  • 原文地址:https://www.cnblogs.com/winditsway/p/12567416.html
Copyright © 2011-2022 走看看