我正在为我的工作做一些工作。我需要提取每个讲座的时间,这样我就可以把它们交给我的老板跟踪。我读过关于美的书。我已经开始上课了,时间是:
<div class="ci-details-container clearfix">
<span class="ci-details">
<i ng-class="::getCurrentLectureIcon()" class="icon-play-sign"></i>
<span>02:29</span>
<!-- ngIf: ::!elementData.content_summary -->
</span>
我是怎么做到的:
timeList=soup.findAll("span",{"class":"ci-details"})
我现在试着用这个正则表达式:
newTimes=timeList.findAll("span",{"\d\d\:\d\d"})
从而导致此错误:
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
newTimes=timeList.find("span",{"\d\d\:\d\d"})
AttributeError: 'ResultSet' object has no attribute 'find'
(我应该改用这个Regex语法吗?[0-9][0-9]\:[0-9][0-9]
)
在我看来,我已经列了一张单子,并把它缩小了。我是对的还是错的?你知道吗
我想我的小名单会有一个findAll,findAll甚至find。你知道吗
findAll
是Beautiful Soup的Tag
类的属性。它不是list
内置的属性。你知道吗因此,我们需要搜索ci\u详细信息列表的内容,并查看
<span class="ci-details">
节点中哪些包含内容与时间字符串匹配的<span>
。你知道吗这个正则表达式使用^和$来指定字符串匹配而不使用任何前导或尾随字符。你知道吗
我得到以下输出:
相关问题 更多 >
编程相关推荐