我正在尝试从一个网站上下载一个视频,他们使用一家名为ooyala的公司来托管他们的视频,所以我认为你无法通过搜索页面上的元素来找到它。我正在尝试使用selenium单击播放按钮,并通过网络选项卡获取视频的url。到目前为止,这是我的代码
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
def get_link():
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
caps = DesiredCapabilities.CHROME
caps['loggingPrefs'] = {'browser': 'ALL'}
url_main = r'https://www.channelnewsasia.com/news/video-on-demand/japanhour'
path = r'C:\Users\User\Downloads\Internet download\chromedriver_win32\chromedriver.exe'
driver = webdriver.Chrome(path, chrome_options=chrome_options,desired_capabilities=caps)
driver.get(url_main)
time.sleep(10)
link = driver.find_element_by_class_name('video__custom-duration')
link.click()
while True:
for entry in driver.get_log('browser'):
print(entry)点击可以工作,但loggingPrefs不能,我认为它返回了错误消息。我试图查找文档,但我找不到DesiredCapabilities字典中还有哪些其他类型的参数。
TLDR:
如何从chrome的网络选项卡中读取内容?
其他信息。
我使用的url仅限于新加坡,所以这里有另一个随机的视频给任何帮助我的人,虽然没有使用ooyala。https://www.rollingstone.com/music/music-news/norwegian-dj-cashmere-cat-goes-spartan-on-with-me-premiere-71196/
如果您使用vpn访问原始url,这里是我试图自动查找的链接https://mediacorp-videosaz.akamaized.net/c642f1d9-bfcd-46fe-8304-b4bf5c236d1e/BsY3hkajE6J_wuuYqP4M6HATpdD8CwlF.ism/QualityLevels(1984000)/Manifest(format=m3u8-aapl)。
发布于 2021-07-13 21:22:54
我使用Selenium获取用于在网络选项卡中手动搜索的信息。
查看下面的链接以了解更多详细信息
https://stackoverflow.com/a/68363046/8491363
Selenium 4.0将正式支持访问Chrome Devtool信息,但它仍处于测试阶段。在3.0上,您可以尝试按照我的建议记录性能。
https://stackoverflow.com/questions/61823103
复制相似问题