【发布时间】:2021-08-17 03:55:22
【问题描述】:
BeautifulSoup 和 python3.9 使用 lmxl 作为解析器,
我想从下图中找到<div, class="playlistAPI..."。
但是当我执行x = soup.find("div", class_="playlistInterface") 并打印时,我得到:
<div class="playlistInterface" style="position: relative; width: 100%; height: 100%">
<div class="mwPlayerContainer player-out">
<div class="videoHolder"><div class="videoDisplay">
<video class="persistentNativePlayer" id="kaltura_player_" kentryid="1_o54seuc8" kpartnerid="1493231" kuiconfid="41642851" kwidgetid="1_3t8nz2gs" poster="data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%01%00%00%00%01%08%02%00%00%00%90wS%DE%00%00%00%01sRGB%00%AE%CE%1C%E9%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%07tIME%07%DB%0B%0A%17%041%80%9B%E7%F2%00%00%00%19tEXtComment%00Created%20with%20GIMPW%81%0E%17%00%00%00%0CIDAT%08%D7c%60%60%60%00%00%00%04%00%01'4'%0A%00%00%00%00IEND%AEB%60%82" preload="none">
</video>
</div></div> </div>
</div>
IE,它没有出现,我使用x.find("div", class_="playlistAPI medialistContainer unselectable k-vertical")找不到它
我尝试了以下thread 中的建议以及从那里链接的线程线索,但我没有运气。
有没有办法做到这一点?还是我遗漏了一些明显的东西?
提前谢谢你。
【问题讨论】:
-
如果可以的话可以提供网址
-
只是因为您需要在类名中包含 Period
.!您正在匹配 4 个不同的类,请使用playlistAPI.medialistContainer.unselectable.k-vertical -
使用句点也返回无。我已经提供了网址。随意尝试一下。
-
@ACB_prgm 你想在那个 div 容器中找到 Lectures 的标题吗??
-
@BhavyaParikh 是的!我正在尝试获取每个讲座的标题和持续时间。
标签: html python-3.x xml beautifulsoup