我是靠谱客的博主 含糊音响,这篇文章主要介绍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 story

The 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标签的全部内容,更多相关python内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(127)

评论列表共有 0 条评论

立即
投稿
返回
顶部