Javascript 尝试使用beautifulsoup刮除iframe

Javascript 尝试使用beautifulsoup刮除iframe,javascript,python,web-scraping,beautifulsoup,web-crawler,Javascript,Python,Web Scraping,Beautifulsoup,Web Crawler,我想抓取一段视频,但Beautfulsoup并没有等待iframe加载。我尝试使用selenium,但google webdriver会等待整个页面加载,这需要花费很长时间。页面加载完成后,我也无法获取页面源代码 这是我用beautifulsoup试过的代码,但我什么也没有得到 def get_vidCode_from_source(source_url): source_code = requests.get(source_url) plain_text = source_co

我想抓取一段视频,但Beautfulsoup并没有等待iframe加载。我尝试使用selenium,但google webdriver会等待整个页面加载,这需要花费很长时间。页面加载完成后,我也无法获取页面源代码

这是我用beautifulsoup试过的代码,但我什么也没有得到

def get_vidCode_from_source(source_url):
    source_code = requests.get(source_url)
    plain_text = source_code.text
    soup = BeautifulSoup(plain_text,"html.parser")
    print(soup.find('iframe'))

get_vidCode_from_source('http://anilinkz.io/one-piece-episode-769?src=3')
因此,尝试在iframe中获取视频链接:


除了selenium,还能获得iFrame还有什么好处?

我知道这有点旧,但要使用selenium并获取页面源代码,请使用以下代码:

from selenium import webdriver
browser = webdriver.Chrome()
browser.get('http://anilinkz.io/one-piece-episode-769?src=3')
soup = BeautifulSoup(browser.page_source, "lxml")
browser.close()
for x in soup.find_all('iframe'):
    print(x)

你到底想提取什么?只是iframe的链接还是视频的链接?根据你函数名称的声音,可能是与视频相关的代码?是的,我想获得视频链接。但是如果我得到整个iframe元素代码也会很好。