简体   繁体   中英

how to find the video tag in html5 using bs4 (python)

In the code below I created a function that tries to get the src from a
video tag in html5 using bs4, but it doesn't seems to work

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

for the record i saw this " How to find specific video html tag using beautiful soup? " but i could not get it to work

Try this (" find_all " instead of " findAll "):

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

Misstyping BS4's "find_all" is one of the most common errors with this library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM