简体   繁体   English

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

[英]How to access network tab in chrome developer tools using python

I'm trying to download a video from a website, they use a company called ooyala to host their videos, so i think you can't find it through searching the elements on the page.我正在尝试从网站下载视频,他们使用一家名为 ooyala 的公司来托管他们的视频,所以我认为您无法通过搜索页面上的元素找到它。 I'm trying to use selenium to click the play button, and get the url of the video through the network tab.我正在尝试使用 selenium 单击播放按钮,并通过网络选项卡获取视频的 url。 This is my code so far到目前为止,这是我的代码

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)

The clicking works but the loggingPrefs doesn't, I think it's returning error messages.点击有效,但 loggingPrefs 没有,我认为它正在返回错误消息。 I've tried to look for the documentation but i can't find what other types of args goes into the DesiredCapabilities dictionary.我试图查找文档,但找不到其他类型的 args 进入 DesiredCapabilities 字典。 Can anyone give me some assistance?谁能给我一些帮助?

TLDR: TLDR:

How do I read from the network tab in chrome?如何从 chrome 中的网络选项卡中读取?

Additional info.附加信息。

The url i'm using is georestricted to singapore, so here's another random video for anyone helping me, not using ooyala though.我使用的 url 仅限于新加坡,所以这是另一个随机视频,供任何帮助我的人使用,但不使用 ooyala。 https://www.rollingstone.com/music/music-news/norwegian-dj-cashmere-cat-goes-spartan-on-with-me-premiere-71196/ https://www.rollingstone.com/music/music-news/norwegian-dj-cashmere-cat-goes-spartan-on-with-me-premiere-71196/

If you accessing the original url with a vpn, heres the link i am trying to find automatically https://mediacorp-videosaz.akamaized.net/c642f1d9-bfcd-46fe-8304-b4bf5c236d1e/BsY3hkajE6J_wuuYqP4M6HATpdD8CwlF.ism/QualityLevels(1984000)/Manifest(format=m3u8-aapl) If you accessing the original url with a vpn, heres the link i am trying to find automatically https://mediacorp-videosaz.akamaized.net/c642f1d9-bfcd-46fe-8304-b4bf5c236d1e/BsY3hkajE6J_wuuYqP4M6HATpdD8CwlF.ism/QualityLevels(1984000)/清单(格式=m3u8-aapl)

I used Selenium to get the information I used to search in the network tab manually.我使用 Selenium 来获取我用来手动在网络选项卡中搜索的信息。

Check out the link below for further details查看下面的链接以获取更多详细信息

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

Selenium 4.0 will officially support accessing Chrome Devtool information but it's still in beta. Selenium 4.0 将正式支持访问 Chrome Devtool 信息,但仍处于测试阶段。 On 3.0, you can try logging performance as I suggested.在 3.0 上,您可以按照我的建议尝试记录性能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以使用 python 访问谷歌浏览器开发者工具的网络选项卡吗? - can I access to network tab of google chrome developer tools with python? 如何使用 Python 访问 Chrome Devtools 网络选项卡中的值? - How to access values in the Chrome Devtools network tab using Python? 如何使用 python selenium 访问 google chrome 开发人员工具上的安全面板? - How to access Security panel on google chrome developer tools with python selenium? Python 请求标头不起作用 - 检查 Chrome 开发者工具 -> 网络 - Python requests header not working - Checked Chrome developer tools -> Network 如何使用 python selenium webdriver 在 Chrome 开发人员工具控制台中进行 fetch 调用 - How to make a fetch call in Chrome developer tools console using python selenium webdriver Python selenium 获取“开发者工具”→网络→媒体日志 - Python selenium get "Developer Tools" →Network→Media logs Cookie未显示在Chrome开发者工具(Django Python)中 - Cookie does not show up in Chrome Developer Tools (Django Python) Python Selenium:使用 execute_cdp_cmd() 捕获 Chrome 开发工具网络请求/响应日志 - Python Selenium : Capture Chrome Dev Tools Network Request/Response Logs using execute_cdp_cmd() 如何在 Python 中使用 Selenium 打开 chrome 开发者控制台? - How to open chrome developer console using Selenium in Python? 如何以编程方式复制Chrome Developer Tools中的请求? - How to programmatically replicate a request found in Chrome Developer Tools?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM