2016-05-19 32 views
1

在下面的代码中,我创建了一个函数,它尝试使用bs4从html5中的
视频标签中获取src,但似乎不起作用如何在html5中使用bs4(python)查找视频标签

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?”,但我不能让它的工作

+0

我相信你应该使用'find_all'而不是'findAll'。 –

回答

0

尝试(的 “find_all ”而不是“ 的findAll”)这样的:

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

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