2016-05-19 30 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」是該庫最常見的錯誤之一。