欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

python soup提取叶子标签_python3用BeautifulSoup抓取div标签

发布时间:2025/10/17 68 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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标签的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。