Dhanushka Amarakoon
Dhanushka Amarakoon

Reputation: 3762

How to get live stream url from script

I need to get the live stream url using a scripting language such as python or shell

eg: http://rt.com/on-air/

I can get the url by using a tool such as the network monitor on Firefox, but i need to be able to get it via a script

Upvotes: 2

Views: 2839

Answers (2)

Andrii Rusanov
Andrii Rusanov

Reputation: 4606

After quick look on requests documentation:

from contextlib import closing

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

If it doesn't help, please check 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

Upvotes: 1

chaos
chaos

Reputation: 490

You need to identify it in the source of the page. It is pretty much the same as using the network tool from FF. For python you can use beautifulsoup to parse the page and get more info out of it... or a simple regex.

Upvotes: 0

Related Questions