【问题标题】:how to find the video tag in html5 using bs4 (python)如何使用 bs4 (python) 在 html5 中找到视频标签
【发布时间】:2016-05-19 11:58:31
【问题描述】:

在下面的代码中,我创建了一个尝试从 a
获取 src 的函数 html5中使用bs4的video标签,但它似乎不起作用

import urllib
from bs4 import BeautifulSoup

def spider(start_at, end):  
i = 39841

while (i + start_at) <= (end + i):
    url = "http://wwww.getvids.org/watch/" + str(i + start_at)
    meet = requests.get(url).text
    bso4 = BeautifulSoup(meet, "html.parser")

    for vidL in bso4.findAll("video", {'class': 'vjs-tech'}):
        print vidL.get("src")

        print 'done'
    start_at += 1

为了记录,我看到了这个“How to find specific video html tag using beautiful soup?”,但我无法让它工作

【问题讨论】:

  • 我相信你应该使用find_all 而不是findAll

标签: python html bs4


【解决方案1】:

试试这个(“find_all”而不是“findAll”):

for vidL in bso4.find_all("video", {'class': 'vjs-tech'}):

错误键入 BS4 的“find_all”是该库最常见的错误之一。

【讨论】:

    猜你喜欢
    • 2014-02-10
    • 2015-12-30
    • 2020-05-16
    • 2012-05-12
    • 2012-08-07
    • 2012-10-11
    • 2011-10-06
    • 1970-01-01
    相关资源
    最近更新 更多