Beautiful Soup 的用法

http://wiki.jikexueyuan.com/project/python-crawler-guide/beautiful-soup.html

 

.contents

tag 的 .content 属性可以将tag的子节点以列表的方式输出

print soup.head.contents 
\#[<title>The Dormouse's story</title>]  

输出方式为列表,我们可以用列表索引来获取它的某一个元素

print soup.head.contents[0]
\#<title>The Dormouse's story</title>  

 

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 kev60712 的頭像
    kev60712

    kevin程式初學

    kev60712 發表在 痞客邦 留言(0) 人氣()