美文网首页
安装beautifulsoup4

安装beautifulsoup4

作者: Retree | 来源:发表于2018-08-27 09:33 被阅读0次

    在win10下,使用pip安装

    先安装beautifulsoup4,然后还需要安装lxml(html解析器)

    pip install beautifulsoup4
    
    pip install lxml
    

    使用beautifulsoup,可以是个文件,也可以是段代码

    from bs4 import BeautifulSoup
    
    soup = BeautifulSoup(open("index.html"),"lxml")
    soup2 = BeautifulSoup("<html>data</html>","lxml")
    

    Beautifu Soup将HTML文档转换成树形结构,每个节点都是Python对象,可以归纳为:Tag,NavigableString,BeautifulSoup,Comment

    相关文章

      网友评论

          本文标题:安装beautifulsoup4

          本文链接:https://www.haomeiwen.com/subject/jliiiftx.html