Skip to main content
 首页 » 编程设计

python之如何从脚本中获取直播网址

2025年05月04日9txw1958

我需要使用python或shell等脚本语言获取直播流地址

例如:http://rt.com/on-air/

我可以使用 Firefox 上的网络监视器等工具获取 url,但我需要能够通过脚本获取它

请您参考如下方法:

快速查看 requests 后文档:

from contextlib import closing 
 
with closing(requests.get('http://rt.com/on-air/', stream=True)) as r: 
    # Do things with the response here. 

如果没有帮助,请检查another way :

import requests 
 
r = requests.get('http://rt.com/on-air/', stream=True) 
 
for line in r.iter_lines(): 
 
    # filter out keep-alive new lines 
    if line: 
        # do some sort of things