【发布时间】:2021-05-01 23:58:41
【问题描述】:
我在使用 BeautifulSoup 和 python 抓取 div 内部而不是它们之间的代码时遇到问题。下面我写了一个html代码我想抓取(data-friendscount,data-followerscount值)
<div data-profileuserid="285904056" data-friendscount="100" data-followerscount="7102" data-followingscount="25" data-arefriends="false" class="hidden ng-isolate-scope"></div>
【问题讨论】:
-
你见过crummy.com/software/BeautifulSoup/bs4/doc/#attributes 吗?你试图获得什么价值?
-
是的,我需要价值观
-
你能再分享一些代码吗,你试过什么?对我来说,这些文档对如何做非常有定论。也许有一个小错字左右。上面的 HTML 是怎么处理的?
-
我无法分享我的代码,因为它不起作用,我不知道如何在 div 中删除数据。我可以给你链接roblox.com/users/285904056/profile -- 正在尝试获取粉丝数
-
soup = BeautifulSoup(html_here)然后tag = soup.div和tag.get(attribute_here)作为启动器(替换_here部分)。
标签: python html beautifulsoup