python soup提取叶子标签_python3用BeautifulSoup抓取div标签
#-*- coding:utf-8 -*-#python 2.7#XiaoDeng#http://tieba.baidu.com/p/2460150866#標簽操作
from bs4 importBeautifulSoupimporturllib.requestimportre#如果是網址,可以用這個辦法來讀取網頁#html_doc = "http://tieba.baidu.com/p/2460150866"#req = urllib.request.Request(html_doc)#webpage = urllib.request.urlopen(req)#html = webpage.read()
html="""
The Dormouse's storyThe Dormouse's story
Once upon a time there were three little sisters; and their names were
,
Lacie and
Tillie;
Lacie
and they lived at the bottom of a well.
加載中…個人資料
- 博客等級:
- 博客積分:0
- 博客訪問:3,971
- 關注人氣:0
- 獲贈金筆:0支
- 贈出金筆:0支
- 榮譽徽章:
...
"""soup= BeautifulSoup(html, 'html.parser') #文檔對象#類名為xxx而且文本內容為hahaha的div
for k in soup.find_all('div',class_='atcTit_more'):#,string='更多'
print(k)#
更多>>總結
以上是生活随笔為你收集整理的python soup提取叶子标签_python3用BeautifulSoup抓取div标签的全部內容,希望文章能夠幫你解決所遇到的問題。

- 上一篇: 分布式缓存redis 方案_Redis缓
- 下一篇: python x y z 1_Pytho