首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用python访问chrome开发人员工具中的网络选项卡

如何使用python访问chrome开发人员工具中的网络选项卡
EN

Stack Overflow用户
提问于 2020-05-15 23:40:32
回答 1查看 984关注 0票数 4

我正在尝试从一个网站上下载一个视频,他们使用一家名为ooyala的公司来托管他们的视频,所以我认为你无法通过搜索页面上的元素来找到它。我正在尝试使用selenium单击播放按钮,并通过网络选项卡获取视频的url。到目前为止,这是我的代码

代码语言:javascript
复制
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)

EN

回答 1

Stack Overflow用户

发布于 2021-07-13 21:22:54

我使用Selenium获取用于在网络选项卡中手动搜索的信息。

查看下面的链接以了解更多详细信息

https://stackoverflow.com/a/68363046/8491363

Selenium 4.0将正式支持访问Chrome Devtool信息,但它仍处于测试阶段。在3.0上,您可以尝试按照我的建议记录性能。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61823103

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档